我正在编写脚本以便轻松上传许多文件。我已尝试fyneworks plugin,但文件名未出现在使用 tiny_mce 的表单中。这是代码:
$("document").ready(function () {
var i = 0; //iteration for Inputted File
var max = 5; //max file uploaded
createStatus(); //generate status container
$('.imageNow').change(function() {
if($(this).val()) {
var ext = $(this).val().split('.').pop().toLowerCase();
var allow = [ 'gif', 'png', 'jpg', 'jpeg' ];
if (jQuery.inArray(ext, allow) != -1) { //validation true
addImgInput($(this).clone());
$(this).addClass('imgOK');
$(this).removeClass('imageNow');
addImgList($(this).val());
removeImgStatus();
i++;
}
else {
addImgStatus();
$(this).remove();
addImgInput();
}
}
return false;
});
});
这是我使用的另一个功能:
function addImgInput(inputClone) {
$(inputClone).prependTo( $('#upload_images') ); //div container for generated InputFileImg
};
function addImgList(listingImg) {
$('#list_image_file').append('<li>' + listingImg + '</li>' ); //list all images that have been inputted
}
function createStatus() {
$('#upload_images').append('<small class="status"></small>'); //error display container
}
function addImgStatus() {
$('.status').append('* Wrong File Extension'); //error display text
}
function removeImgStatus() {
$('.status').empty();
}
Mmm..yeah尚未完成,因为当我尝试使用 imageNow 类生成另一个Inputfile时, $('。imageNow')。change(function() 不再有用了。有人可以帮助我吗?谢谢
答案 0 :(得分:1)
我真的不明白这是不是你的问题:
当我尝试生成另一个时 带有imageNow类的inputfile ,. $('。imageNow')。change(function()是 不再工作了。
但要解决这个问题,你必须使用.live
:
$('.imageNow').live('change', function() {
// your code
});