dhawalBhanushali
dhawalBhanushali

Reputation: 95

Jquery extend function in Ember.js

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

Answers (1)

mangatinanda
mangatinanda

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

Related Questions