dynamically setting properties in uploadify

后端 未结 2 1368
滥情空心
滥情空心 2020-12-19 22:27

is it possible to add a new property to a previously declared object? Here is some code to clarify (with the uploadify jquery plugin):

$(\'#featuredimageuplo         


        
相关标签:
2条回答
  • 2020-12-19 23:13

    I believe what you are looking for is this:

    $("#form").submit(function(){
        var $upload = $("#featuredimageupload");
        $upload.uploadifySettings('scriptData', { key : value });
        $upload.uploadifyUpload(); // Triggers the upload to start.
    });
    

    You can also get the current value by leaving the second parameter off:

    var currentSetting = $upload.uploadifySettings('scriptData');
    
    0 讨论(0)
  • 2020-12-19 23:33

    Yes it is possible to add properties (dynamic or otherwise) to an existing Javascript object). You can just use the [] operator to add a dynamic property to an object. For example:

    var key = 'foo';
    var obj = {param: 'value'};
    obj[key] = 'bar';
    alert(obj.foo); // bar
    
    0 讨论(0)
提交回复
热议问题