[英]jQuery: $(this) vs. this.$()
在Ember.js的文檔中 ,他們有一個jQuery代碼片段,其語法如下:
this.$().button();
這個片段只是將this
轉換為jQuery對象,以便可以在其上調用jQuery UI .button()
函數嗎?
這個片段是否相同?
$(this).button();
源代碼解釋如下:
/**
Returns a jQuery object for this view's element. If you pass in a selector
string, this method will return a jQuery object, using the current element
as its buffer.
For example, calling `view.$('li')` will return a jQuery object containing
all of the `li` elements inside the DOM element of this view.
@param {String} [selector] a jQuery-compatible selector string
@returns {Ember.CoreQuery} the CoreQuery object for the DOM node
*/
$: function(sel) {
return this.invokeForState('$', sel);
},
所以回答你的問題:不,它與$(this)
,它會將ember視圖實例包裝在jQuery對象中......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.