无法读取未定义的属性“不透明度”

时间:2013-08-28 12:33:50

标签: asp.net-mvc-4 fine-uploader

我正在以这种方式加载精细上传器:

var uploader = new qq.FineUploaderBasic({
                button: $("#docAddHref"),
                request: {
                    endpoint: 'server/handleUploads'
                },
                validation: {
                    allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
                    sizeLimit: 204800 // 200 kB = 200 * 1024 bytes
                },
                callbacks: {
                    onSubmit: function (id, fileName) {
                        $messages.append('<div id="file-' + id + '" class="alert" style="margin: 20px 0 0"></div>');
                    },
                    onUpload: function (id, fileName) {
                        $('#file-' + id).addClass('alert-info')
                                        .html('<img src="client/loading.gif" alt="Initializing. Please hold."> ' +
                                              'Initializing ' +
                                              '“' + fileName + '”');
                    },
                    onProgress: function (id, fileName, loaded, total) {
                        if (loaded < total) {
                            progress = Math.round(loaded / total * 100) + '% of ' + Math.round(total / 1024) + ' kB';
                            $('#file-' + id).removeClass('alert-info')
                                            .html('<img src="client/loading.gif" alt="In progress. Please hold."> ' +
                                                  'Uploading ' +
                                                  '“' + fileName + '” ' +
                                                  progress);
                        } else {
                            $('#file-' + id).addClass('alert-info')
                                            .html('<img src="client/loading.gif" alt="Saving. Please hold."> ' +
                                                  'Saving ' +
                                                  '“' + fileName + '”');
                        }
                    },
                    onComplete: function (id, fileName, responseJSON) {
                        if (responseJSON.success) {
                            $('#file-' + id).removeClass('alert-info')
                                            .addClass('alert-success')
                                            .html('<i class="icon-ok"></i> ' +
                                                  'Successfully saved ' +
                                                  '“' + fileName + '”' +
                                                  '<br><img src="img/success.jpg" alt="' + fileName + '">');
                        } else {
                            $('#file-' + id).removeClass('alert-info')
                                            .addClass('alert-error')
                                            .html('<i class="icon-exclamation-sign"></i> ' +
                                                  'Error with ' +
                                                  '“' + fileName + '”: ' +
                                                  responseJSON.error);
                        }
                    },
                    onError: function (id, name, reason, xhr) {
                        $('#fubErrorAlert .message').text(reason);

                        $('#fubErrorAlert button').click(function () {
                            $('#fubErrorAlert').hide();
                        });

                        $('#fubErrorAlert').show();
                    }
                }
            });
            console.log('uploader called');
            uploader();

当页面加载时,我收到此javascript错误:

  

无法读取未定义的属性'opacity'

我通过Nuget Pacakage for ASP.NET安装了FineUploader

https://github.com/Widen/fine-uploader-server/tree/master/ASP.NET%20MVC%20C%23

请指教!

1 个答案:

答案 0 :(得分:1)

您的按钮选项可能是问题所在。你应该把它改成:

button: $("#docAddHref")[0]

如果你想要传递一个jQuery对象,你需要下载并使用Fine Uploader的jQuery插件。有关http://docs.fineuploader.com/integrating/jquery.html

插件的更多信息