附加文件输入不适用于ajaxfileupload

appending file inputs not working on ajaxfileupload

本文关键字:适用于 ajaxfileupload 不适用 输入 文件      更新时间:2023-09-26

我正在使用一个名为ajaxfileupload的插件https://github.com/jfeldstein/jQuery.AjaxFileUpload.js

我的问题是,当我动态附加输入文件时,插件事件不会应用于新附加的输入文件。

这就是点击文件输入时调用插件的方式:

$("#mcq_option_list input[type=file], #question_name input[type=file], #test").ajaxfileupload({

这是我的附加函数:

$(this).before('<div class="answerswer_div"><input id="'+new_num+'" class="rb" type="radio" value="'+new_num+'"><label for="'+new_num+'" class="mc_label"><strong class="abcdWrapper">'+next_letter+'</strong></label><div class="fake-input"><input type="text" class="long_input" placeholder="Enter Sub Option here..." name="data[Quiz][option][]" autocomplete="off"><span></span><div class="inputWrapper"> Upload Image<input class="fileInput" type="file" name="data[Quiz][image]['+new_num+']" id="test"></div></div><a href="#" class="delete-scale-question"></a></div>');

感谢您提前提供的帮助。

我已经有了答案,我应该将所有内容都包含在"on"语句中。

这是完整的代码:

$("#mcq_contain").on("click", "#mcq_option_list input[type=file], #question_name input[type=file], #test", function(){
     $(this).ajaxfileupload({
          // Code goes here
     }); 
});