Valums qq.FileUploader doesn't work when it

2019-08-27 00:49发布

I use Valums qq.FileUploader(ex-AjaxUpload) plugin for uploading in my Asp.net mvc 3 application...

I have some button in my page add-newimage, and by clicking in it I get modal window, and I load data into that window by loading Partial View.

And in that partial view I have button upload-image , in which I want to initilaize my qq.FileUploader, but it doesn't work anywhere...

Here is code

      $("#add-newimage").click(function () {
            $("#add-image").load('/Design/AddImage/', function () {
                $("#add-image").dialog('open');

                     var uploader= new qq.FileUploader({
                    element: document.getElementById("upload-image"),
                    action: '/Design/UploadImage',
                    allowedExtensions: ['jpg'],
                    onComplete: function (id, fileName, responseJSON) {
                        $("#hidden-path input").html("/Img/Temp/@User.Identity.Name/" + file);
                        alert($("#hidden-path input").html());
                    }

                     }); 
            }); 
        });

How can I make it work?

1条回答
相关推荐>>
2楼-- · 2019-08-27 01:43

I would try to put the uploader code in the open event of your dialog.

$("#add-image").dialog({
  open : function(event, ui) {
      var uploader= new qq.FileUploader({
        element: document.getElementById("upload-image"),
        action: '/Design/UploadImage',
        allowedExtensions: ['jpg'],
        onComplete: function (id, fileName, responseJSON) {
          $("#hidden-path input").html("/Img/Temp/@User.Identity.Name/" + file);
            alert($("#hidden-path input").html());
          }
  }
});

..

$("#add-newimage").click(function () {
  $("#add-image").load('/Design/AddImage/', function () {
    $("#add-image").dialog('open');
  });
});
查看更多
登录 后发表回答