How to use third party npm packages with ember cli app

The easiest and recommended answer is to use ember-browserify. (as support for bower packages will be removed in the future.) This is an example for using the npm package dexie within an Ember CLI app. Install browserify: npm install ember-browserify –save-dev Install dexie (or whatever module you need): npm install dexie –save-dev Import the module … Read more

Handling errors with the (now default) Ember Data JSON-API adapter

Note the answer below is based on the following versions: DEBUG: ——————————- ember.debug.js:5442DEBUG: Ember : 1.13.8 ember.debug.js:5442DEBUG: Ember Data : 1.13.9 ember.debug.js:5442DEBUG: jQuery : 1.11.3 DEBUG: ——————————- The error handling documentation is unfortunately scattered around at the moment as the way you handle errors for the different adapters (Active, REST, JSON) are all a bit … Read more

Using Ember.js, how do I run some JS after a view is rendered?

You need to override didInsertElement as it’s “Called when the element of the view has been inserted into the DOM. Override this function to do any set up that requires an element in the document body.” Inside the didInsertElement callback, you can use this.$() to get a jQuery object for the view’s element. Reference: https://github.com/emberjs/ember.js/blob/master/packages/ember-views/lib/views/view.js

Ember-data embedded records current state?

Using the ActiveModelSerializer you can include the EmbeddedRecordsMixin which allows you to use embedded records. (In the canary versions, 1.0 beta 9+, you can use the JsonSerializer/RESTSerializer as well) Serializer App.ColorSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, { attrs: { foos: {embedded: ‘always’} } }); Models App.Color = DS.Model.extend({ color: DS.attr(), foos: DS.hasMany(‘foo’) }); App.Foo = DS.Model.extend({ name: DS.attr() … Read more