我正在使用这个html5文件上传器插件,但它在Google Chrome上有一个错误,我无法理解并修复它。它在Firefox上工作正常。
当您第一次点击时,选择并点击确定从桌面上传文件,它应该提醒一个消息,例如’.button-1′ – 取决于你点击哪个上传按钮。
- $(".upload-file",object_parent).change(function() {
- ...
- ...
- alert($cm.selector);
- });
任何想法这个插件出了什么问题?
- (function($){
- // Attach this new method to jQuery
- $.fn.extend({
- // This is where you write your plugin's name
- upload_file_html5: function(options) {
- // Set the default values,use comma to separate the settings,example:
- var defaults = {
- objectSuperparent: '.media'
- }
- var options = $.extend(defaults,options);
- var o = options;
- var $cm = this.click(function(e){
- // <a> button is the object in this case.
- var object = $(this);
- // Get other info from the element belong to this object group.
- var object_href = object.attr('href');
- var object_parent = object.parent();
- alert($cm.selector);
- // Trigger the click event on the element.
- // Due to security policies triggering click on the input type=file is not allowed/supported in some browsers and Opera is one of them.
- //$('input[type=file]').trigger('click'); // or:
- $(".upload-file",object_parent).click();
- return false;
- });
- // Trigger ajax post when ever the file is changed by the user.
- var $cm_2 = $(".upload-file").change(function(){
- // <input> is the object in this case.
- var object = $(this);
- var object_form = object.parent();
- var object_superparent = object.parents(o.objectSuperparent);
- var path_config = $($cm.selector,object_superparent).attr('href');
- var path_post = object_form.attr('action');
- alert($cm.selector);
- //alert(path_config);
- ....
- ....
- });
- }
- });
- })(jQuery);
Chrome可以正常工作,但最近刚刚失败,可能Chrome已将最新版本更新到我的机器,此更新会导致错误?