jquery file upload报错 TypeError: Object [object Object] has no method 'progressbar'
2014-08-01 16:02
585 查看
本周在用jquery file upload这个插件做文件上传功能。但是打开页面的时候,浏览器控制台报错:
TypeError: Object [object Object] has no method 'progressbar'
然后看了一下具体的位置,在jquery.fileupload-jquery-ui.js的_create方法中,就是这个方法的最后一句:.end().find('.progress').progressbar();_create: function () {
this._super();
this.element
.find('.fileupload-buttonbar')
.find('.fileinput-button').each(function () {
var input = $(this).find('input:file').detach();
$(this)
.button({icons: {primary: 'ui-icon-plusthick'}})
.append(input);
})
.end().find('.start')
.button({icons: {primary: 'ui-icon-circle-arrow-e'}})
.end().find('.cancel')
.button({icons: {primary: 'ui-icon-cancel'}})
.end().find('.delete')
.button({icons: {primary: 'ui-icon-trash'}})
.end().find('.progress').progressbar();
},似乎是找到了class为progress的组件,但是这个对象没有progressbar()这个方法,然后在几个相关的js文件中找了一圈,都没有找到progressbar()方法的定义。难道是我没有引用定义这个方法的js文件?。。。
然后百度,一条有价值的信息都没有。没办法,翻墙用谷歌,一下子就找到了有用的信息:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202012/14/1e628284bc1688ac06bc82883e906abf)
从这两个老外的对话看,应该就是没有引用相关的js文件了。看到“jQuery UI library” 这个词,忽然想到些什么。
刚开始做这个功能的时候,各种插件都是从这个网址下的:http://plugins.jquery.com/blueimp-file-upload/
![](https://oscdn.geek-share.com/Uploads/Images/Content/202012/14/4cd2a05f030bdb82d2de7cce41ede697)
得到的是一个名为blueimp-jQuery-File-Upload-9.7.0-0-g91b20e5的文件夹,里面有一堆的js文件。而问题就来了,导致progressbar报错的那个没有被引用的文件,恰恰不在这个文件夹里。而需要从另外一个网址下,百度jQuery UI library,进入第一个网址:http://jqueryui.com/
![](https://oscdn.geek-share.com/Uploads/Images/Content/202012/14/3a8046be3c9b689f3493db1f285ceee5)
这个和刚才不同,这个更多得提供了UI方面的内容,下载得到的文件夹名为:jquery-ui-1.11.0
而在这个文件夹里,有一个名为jquery-ui.js的文件,这个文件中才定义了progressbar方法,然后将这个js引用到页面上,OK,不报错了。
老外虽然技术很牛,能做出jquery这一套插件,。。。但是既然上传功能是比较完整的一个大模块,怎么就不能把相关的js一起打包进去让别人下载呢。。。害我绕了这么一大圈。
TypeError: Object [object Object] has no method 'progressbar'
然后看了一下具体的位置,在jquery.fileupload-jquery-ui.js的_create方法中,就是这个方法的最后一句:.end().find('.progress').progressbar();_create: function () {
this._super();
this.element
.find('.fileupload-buttonbar')
.find('.fileinput-button').each(function () {
var input = $(this).find('input:file').detach();
$(this)
.button({icons: {primary: 'ui-icon-plusthick'}})
.append(input);
})
.end().find('.start')
.button({icons: {primary: 'ui-icon-circle-arrow-e'}})
.end().find('.cancel')
.button({icons: {primary: 'ui-icon-cancel'}})
.end().find('.delete')
.button({icons: {primary: 'ui-icon-trash'}})
.end().find('.progress').progressbar();
},似乎是找到了class为progress的组件,但是这个对象没有progressbar()这个方法,然后在几个相关的js文件中找了一圈,都没有找到progressbar()方法的定义。难道是我没有引用定义这个方法的js文件?。。。
然后百度,一条有价值的信息都没有。没办法,翻墙用谷歌,一下子就找到了有用的信息:
从这两个老外的对话看,应该就是没有引用相关的js文件了。看到“jQuery UI library” 这个词,忽然想到些什么。
刚开始做这个功能的时候,各种插件都是从这个网址下的:http://plugins.jquery.com/blueimp-file-upload/
得到的是一个名为blueimp-jQuery-File-Upload-9.7.0-0-g91b20e5的文件夹,里面有一堆的js文件。而问题就来了,导致progressbar报错的那个没有被引用的文件,恰恰不在这个文件夹里。而需要从另外一个网址下,百度jQuery UI library,进入第一个网址:http://jqueryui.com/
这个和刚才不同,这个更多得提供了UI方面的内容,下载得到的文件夹名为:jquery-ui-1.11.0
而在这个文件夹里,有一个名为jquery-ui.js的文件,这个文件中才定义了progressbar方法,然后将这个js引用到页面上,OK,不报错了。
老外虽然技术很牛,能做出jquery这一套插件,。。。但是既然上传功能是比较完整的一个大模块,怎么就不能把相关的js一起打包进去让别人下载呢。。。害我绕了这么一大圈。
相关文章推荐
- jQuery File upload, Uncaught TypeError: Object function ... ... has no method 'widget'
- Uncaught TypeError: Object [object Object] has no method 'live' 报错
- 当使用JQuery的"$",抛异常Uncaught TypeError: Object #<Object> has no method 'ajax'
- 使用ajaxfileupload插件提示Uncaught TypeError:has no method 'handleError'
- WebView注入Java对象注意事项 [INFO:CONSOLE(475)] "Uncaught TypeError: Object [object Object] has no method
- Uncaught TypeError: Object #<HTMLDivElement> has no method 'attr'
- Android js交互错误:Uncaught TypeError: Object [object Object] has no method 'xxx'
- 出现TypeError: Object #<Object> has no method 'createClient' 错误
- Uncaught TypeError: Object [object Object] has no method 'xxx'
- Uncaught TypeError: Object #<Object> has no method 'addEvents' ext-all-debug异常
- JS调用Android中的方法时出现 "Uncaught TypeError: Object [object Object] has no method
- 【Android】Web Console: Uncaught TypeError: Object [object Object] has no method 'xxx'
- ztree “Uncaught TypeError: Object # has no method 'toLowerCase'”
- Uncaught TypeError: Object [object Object] has no method 'highcharts'
- Uncaught TypeError: Object #<Document> has no method 'load'
- Uncaught TypeError: Object #<Object> has no method 'addEvents'
- Android webview js 调用java方法报错"Uncaught TypeError: Object [object Object] has no method xx
- Uncaught TypeError: Object #<Object> has no method 'addEvents'
- android中java和JS互相调用,Web Console: Uncaught TypeError: Object [object Object] has no method
- TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'