Reputation: 95
Is there a way to create equivalent of following code in Ember.js
jQuery.fn.extend({
functionName: function(myValue){}
});
Also I want this function to be global. This function will be used as
$('textarea').functionName('value');
Upvotes: 1
Views: 158
Reputation: 754
If you want to extend jQuery and add a function of your own, do it in the initializer. Add the below code in app/initializers/jquery-extend.js
(Name it as you wish.)
import Ember from 'ember';
export default Ember.Object.create({
name: 'Extend jQuery',
initialize() {
jQuery.fn.extend({
functionName: function(myValue){}
});
}
});
Now, you can use $().functionName()
anywhere in your ember app.
Upvotes: 2