jeudi 5 mars 2015

Unable to load jquery plugins in Ember

First of all: I already tried this answer: Using jquery in Ember-cli which seems to be the canonical way of adding a jQuery plugin to ember.


I was following this tutorial: http://ift.tt/1BbHrLy


I installed the plugins using bower, and then added the imports to Brocfile.js.


Here's my Brocfile.js:



/* global require, module */

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

var app = new EmberApp({
compassOptions: {
outputStyle: 'expanded'
}
});

app.import('bower_components/ember-uploader/dist/ember-uploader.js');
app.import('bower_components/moment/moment.js');
app.import('bower_components/jquery.inputmask/dist/jquery.inputmask.bundle.min.js');

module.exports = app.toTree();


The components are all correctly located at their import paths thanks to bower.


And here's the component at components/input-mask.js:



import Ember from 'ember';

export default Ember.TextField.extend({
initializeMask: function() {
var mask = this.get('mask');

this.$().inputmask(mask, {
onBeforeMask: function(value) {
if (mask === 'mm/dd/yyyy') {
return moment(new Date(value)).format('L');
}
}
});

// The input mask changes the value of the input from the original to a
// formatted version. We need to manually send that change back to the
// controller.
this.set('value', this.$().val());
}.on('didInsertElement')
});


But in Chrome's console I get the error: Uncaught TypeError: undefined is not a function for this.$().inputmask.


Am I missing something else to import a plugin to jQuery?





Aucun commentaire:

Enregistrer un commentaire