博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jquery.fileupload-image-editor.js
阅读量:4594 次
发布时间:2019-06-09

本文共 4581 字,大约阅读时间需要 15 分钟。

 

jquery.fileupload-image-editor.js中

_initEventHandlers: function () {            this._super();            var handlers = {};            handlers[this.options.uploadImageEditorPreviewSelector] = this._previewHandler.bind(this);            this._on(this.options.filesContainer, handlers);        },

 

jquery.ui.widget.js

_on: function( suppressDisabledCheck, element, handlers ) {        var delegateElement,            instance = this;        // no suppressDisabledCheck flag, shuffle arguments        if ( typeof suppressDisabledCheck !== "boolean" ) {            handlers = element;            element = suppressDisabledCheck;            suppressDisabledCheck = false;        }        // no element argument, shuffle and use this.element        if ( !handlers ) {            handlers = element;            element = this.element;            delegateElement = this.widget();        } else {            element = delegateElement = $( element );            this.bindings = this.bindings.add( element );        }

 

遇到错误  

是因为找不到

uploadTemplateId: 'template-upload',

Uncaught TypeError: Cannot read property 'innerHTML' of null

at Function.tmpl.load (tmpl.js:38)

tmpl.load = function (id) {

return document.getElementById(id).innerHTML
}

at tmpl (tmpl.js:21)

var tmpl = function (str, data) {

var f = !/[^\w\-.:]/.test(str)
? (tmpl.cache[str] = tmpl.cache[str] || tmpl(tmpl.load(str)))
: new Function( // eslint-disable-line no-new-func
tmpl.arg + ',tmpl',
'var _e=tmpl.encode' +
tmpl.helper +
",_s='" +
str.replace(tmpl.regexp, tmpl.func) +
"';return _s;"
)
return data
? f(data, tmpl)
: function (data) {
return f(data, tmpl)
}
}

at $.<computed>.<computed>._initTemplates (jquery.fileupload-ui.js:657)

_initTemplates: function () {

var options = this.options;
options.templatesContainer = this.document[0].createElement(
options.filesContainer.prop('nodeName')
);
if (tmpl) {
if (options.uploadTemplateId) {
options.uploadTemplate = tmpl(options.uploadTemplateId);
}
if (options.downloadTemplateId) {
options.downloadTemplate = tmpl(options.downloadTemplateId);
}
}
}

at $.<computed>.<computed>._initTemplates (jquery.ui.widget.js:127)
at $.<computed>.<computed>._initSpecialOptions (jquery.fileupload-ui.js:677)

_initSpecialOptions: function () {

this._super();
this._initFilesContainer();
this._initTemplates();
},

at $.<computed>.<computed>._initSpecialOptions (jquery.ui.widget.js:127)
at $.<computed>.<computed>._create (jquery.fileupload.js:1381)

_create: function () {

this._initDataAttributes();
this._initSpecialOptions();
this._slots = [];
this._sequence = this._getXHRPromise(true);
this._sending = this._active = 0;
this._initProgressObject(this);
this._initEventHandlers();
},

at $.<computed>.<computed>._create (jquery.ui.widget.js:127)
at $.<computed>.<computed>._super (jquery.ui.widget.js:114)
at $.<computed>.<computed>._create (jquery.fileupload-process.js:167)

_create: function () {

this._super();
this._processing = 0;
this._processingQueue = $.Deferred().resolveWith(this)
.promise();
}

 

 

 

 

扩展阅读

_on( [suppressDisabledCheck ] [, element ], handlers )Returns: ()

Binds event handlers to the specified element(s). Delegation is supported via selectors inside the event names, e.g., "
click .foo". The
_on() method provides several benefits of direct event binding:
  • Maintains proper this context inside the handlers.
  • Automatically handles disabled widgets: If the widget is disabled or the event occurs on an element with the ui-state-disabled class, the event handler is not invoked. Can be overridden with the suppressDisabledCheck parameter.
  • Event handlers are automatically namespaced and cleaned up on destroy.
  • suppressDisabledCheck (default:
    false)
    Type:
    Whether or not to bypass the disabled check.
  • element
    Type:
    Which element(s) to bind the event handlers to. If no element is provided,
    this.element is used for non-delegated events and is used for delegated events.
  • handlers
    Type:
    An object in which the keys represent the event type and optional selector for delegation, and the values represent a handler function to be called for the event.
Code examples:

Prevent the default action of all links clicked within the widget's element.

this._on( this.element, {  "click a": function( event ) {    event.preventDefault();  }});

 

 

定义和用法

closest() 方法返回被选元素的第一个祖先元素。

祖先是父、祖父、曾祖父,依此类推。

DOM 树:该方法从当前元素向上遍历,直至文档根元素的所有路径(<html>),来查找 DOM 元素的第一个祖先元素。

该方法与  类似,都是向上遍历 DOM 树,不同点是:

closest()

  • 从当前元素开始
  • 沿 DOM 树向上遍历,并返回匹配所传递的表达式的第一个单一祖先
  • 返回包含零个或一个元素的 jQuery 对象

parents()

  • 从父元素开始
  • 沿 DOM 树向上遍历,并返回匹配所传递的表达式的所有祖先
  • 返回包含零个、一个或多个元素的 jQuery 对象

 

转载于:https://www.cnblogs.com/chucklu/p/11102490.html

你可能感兴趣的文章
Hibernate3注解[转]
查看>>
Scrapy简单入门及实例讲解
查看>>
另外一种设置沉浸式标题栏的方式
查看>>
ASP.NET MVC 1.0 Website Programming: Problem - Design - Solution
查看>>
vim使用入门
查看>>
深入解析AsyncTask
查看>>
adb 调系统时间
查看>>
前端开发-CSS 语法
查看>>
顺利通过EMC实验(14)
查看>>
usaco Cow Pedigrees
查看>>
php自带压缩类压缩文件夹
查看>>
【转】Install Win32 OpenSSH (test release)
查看>>
LA 4123 (计数 递推) Glenbow Museum
查看>>
SPOJ 375 树链剖分 QTREE - Query on a tree
查看>>
JavaScript对json对象数组排序(按照某个属性升降序排列)
查看>>
关于 注册页面浏览器自动添加账号密码问题?
查看>>
Python之装饰器
查看>>
04Array
查看>>
MeteoInfoLab脚本示例:计算不同区域平均值
查看>>
Spring -- 全注解下的IoC(1)
查看>>