mercredi 1 juillet 2015

jQuery Plugin Not Available in Ember Component

I have a component that uses a jQuery plugin to format numbers. This is the plugin: http://ift.tt/1H0V4A3

I include the plugin in my Brocfile (using ember-cli)

app.import('vendor/jquery.format-1.3.min.js');

In my component I can successfully access my component like:

didInsertElement: function() {
  var formattedNum = $.format.number(val, '###,###.##');
  this.set('val', formattNum');
}

However, I keep getting complaints from the ember that it doesn't recognize the '$' variable. I believe the proper way of access the underlying jQuery variable is doing the following:

didInsertElement: function() {
  var formattedNum = this.$.format.number(val, '###,###.##');
  this.set('val', formattNum');
}

Unfortunately, when I do this, I always receive the error: 'Cannot read property 'number' of undefined. Is this a different way to access this method? I've tried this.$().format.number(..) and this.$.format.number(...). Both fail.

Andrew




Aucun commentaire:

Enregistrer un commentaire