jquery.fileupload-image-editor.js

 

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();
}

 

 

 

 

擴展閱讀

https://api.jqueryui.com/jQuery.widget/#method-_on

_on( [suppressDisabledCheck ] [, element ], handlers )Returns: jQuery (plugin only)

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: Boolean
    Whether or not to bypass the disabled check.
  • element
    Type: jQuery
    Which element(s) to bind the event handlers to. If no element is provided, this.element is used for non-delegated events and the widget element is used for delegated events.
  • handlers
    Type: Object
    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();
  }
});

 

 

https://www.runoob.com/jquery/traversing-closest.html

定義和用法

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

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

DOM 樹:該方法從當前元素向上遍歷,直至文檔根元素的全部路徑(<html>),來查找 DOM 元素的第一個祖先元素。

該方法與 parents() 相似,都是向上遍歷 DOM 樹,不一樣點是:

closest()

  • 從當前元素開始
  • 沿 DOM 樹向上遍歷,並返回匹配所傳遞的表達式的第一個單一祖先
  • 返回包含零個或一個元素的 jQuery 對象

parents()

  • 從父元素開始
  • 沿 DOM 樹向上遍歷,並返回匹配所傳遞的表達式的全部祖先
  • 返回包含零個、一個或多個元素的 jQuery 對象
相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息