jQuery File Upload not working when file input dynamically created

后端 未结 4 2100
天涯浪人
天涯浪人 2020-12-30 14:33

i am using this jquery uploader (http://blueimp.github.io/jQuery-File-Upload/basic.html) and it works fine when the file input is put in the raw code of the site, however i

4条回答
  •  囚心锁ツ
    2020-12-30 14:58

    Just bind the upload function with a static identifier at first. Here, 'document' is the static identifier. You can use anything like this that has not been added dynamically. Usually, document is used more often.

    $(document).on('click', '.fileupload', function () {
        $('.fileupload').fileupload({
            dataType: 'json',
            done: function (e, data) {
                $.each(data.result.files, function (index, file) {
                    alert(file.name);
                    //$('

    ').text(file.name).appendTo(document.body); }); } }); });

提交回复
热议问题