uploadify 最初工作正常。但是当我使用 ajax 调用重新填充表时,uploadify 不会初始化。同样,jquery-ui 的 .sortable 在同一次调用之后也没有被初始化。
var allimages = [];
$('.bulkupload').each(function() {
var $bulkupload = $(this);
$bulkupload.uploadify({
'swf' : 'uploadify.swf',
'uploader' : 'bulkupload.php',
'auto' : true,
'multi' : true,
'buttonText': 'Upload Images',
'onUploadSuccess' : function(file, data, response) {
if (data == "1") {
var filename = file.name;
if ($.inArray(filename, allimages) > -1) {
var fi = $.inArray(filename, allimages);
allimages.splice(fi, 1);
}
else {
allimages.push(filename);
}
var productid = $bulkupload.attr("prodid");
var sortablename = "#sortable-"+productid;
$(sortablename).append("<li filename=\""+filename+"\" style=\"list-style: none;\" class=\"ui-state-default\"><div class=galleryimages><img src=\"products/"+productid+"/"+filename+"\" width=100 border=0><span class=deleteimageicon filename=\""+filename+"\"><img src=\"images/delete.png\" border=0></span></div></li>");
}
}
});
});
$(".sortable").sortable({
update: function(event, ui) {
var pid = $(this).attr("pid");
var images = $(this).sortable('toArray', {attribute: 'filename'});
var dataString = "images="+images+"&pid="+pid+"&action=bulkimageorder";
$.ajax({
type: "POST",
url: "filename.php",
data: dataString,
cache: false,
success: function(html) {
}
});
}
});
$(".sortable").disableSelection();