2015-03-25 67 views
0

我想,我按下這裏uploadify如何讓我按下

$(".J-fileup").uploadify({ 
    'formData': {}, 
     'swf': '/assets/uploadify/uploadify.swf', 
     'uploader': '/admin/resource/upload', 
     'cancelImg': '/assets/uploadify/uploadify-cancel.png', 
     'onUploadSuccess': function (file, data, response) { 
     var data = JSON.parse(data); 
     if (data.status == 1) { 
      //--I want id of the button that I pressed here 
     } 
    } 

}); 

回答

0

按鈕的ID按鈕的ID,您甚至可以使用:

$(".J-fileup").each(function() { 
    var $jfileup = $(this); 
    // Now you can use $jfileup.attr('id') to get the id. 
    $jfileup.uploadify({ 
    'formData': {}, 
     'swf': '/assets/uploadify/uploadify.swf', 
     'uploader': '/admin/resource/upload', 
     'cancelImg': '/assets/uploadify/uploadify-cancel.png', 
     'onUploadSuccess': function (file, data, response) { 
     var data = JSON.parse(data); 
     if (data.status == 1) { 
      // use $jfileup.attr('id') 
      //--I want id of the button that I pressed here 
     } 
    } 

}); 
}); 
0

你可以做到以下幾點:

'onUploadSuccess': function (file, data ,response,event) { 
    var data = JSON.parse(data); 
     if (data.status == 1) { 
      var buttonId = event.target.id; 
      if(typeof buttonId!= 'undefined'){ 
        //Do what you want to do here. 
      } 

     } 
} 
0

使用onSelect回調uploadify

'onSelect': function(event, ID, fileObj) { 
    var triggerId = $(event.target).attr("id"); //here you get the id of the object. 
}, 
相關問題