Ember.js के docs में, वे निम्न सिंटैक्स के साथ एक jQuery कोड स्निपेट ताकि jQuery UI .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).button();
पहला स्निपेट बताता है कि jQuery ऑब्जेक्ट ($) को 'इस' पर एक संपत्ति के रूप में संग्रहीत किया जाता है, संभवतः प्रदूषण वैश्विक दायरे से बचने के लिए, लेकिन मुझे यकीन नहीं है। –
लेकिन इसे निष्पादित किया गया है। और यह लौटता है, इसलिए यह जंजीर है। मुझे लगता है कि यह वैध है, लेकिन मैंने कभी कोशिश करने का विचार नहीं किया होगा ... – jcolebrand
यह करता है। बटन() काम करता है? यदि ऐसा है, तो 'यह' एक jquery वस्तु है। – MMeah