jquery.fileupload-image-editor.js中html
_initEventHandlers: function () { this._super(); var handlers = {}; handlers[this.options.uploadImageEditorPreviewSelector] = this._previewHandler.bind(this); this._on(this.options.filesContainer, handlers); },
jquery.ui.widget.jsnode
_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 ); }
是由於找不到jquery
uploadTemplateId: 'template-upload',
Uncaught TypeError: Cannot read property 'innerHTML' of null
at Function.tmpl.load (tmpl.js:38)api
tmpl.load = function (id) {
return document.getElementById(id).innerHTML
}promise
at tmpl (tmpl.js:21)ide
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)
}
}ui
at $.<computed>.<computed>._initTemplates (jquery.fileupload-ui.js:657)this
_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);
}
}
}spa
at $.<computed>.<computed>._initTemplates (jquery.ui.widget.js:127)
at $.<computed>.<computed>._initSpecialOptions (jquery.fileupload-ui.js:677)eslint
_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();
}
click .foo
". The
_on()
method provides several benefits of direct event binding:
this
context inside the handlers.ui-state-disabled
class, the event handler is not invoked. Can be overridden with the suppressDisabledCheck
parameter.false
)
this.element
is used for non-delegated events and
the widget element is used for delegated events.
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 元素的第一個祖先元素。
該方法與 parents() 相似,都是向上遍歷 DOM 樹,不一樣點是:
closest()
parents()