jeudi 30 avril 2015

setting model from route upon action received in ember.js

I am trying to set a model value from an action received by my route.

//app/routes/index.js
import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
    return {
      trail: null
    };
  },
  actions: {
    event: function(name, value) {
      if (name === 'trail.selected') {
        this.modelFor('map').set('trail', value);
      }
    }
  }
});

when I try to use

 this.modelFor('map').set('trail', value);

I get the following error:

Uncaught TypeError: this.modelFor(...).set is not a function

When I try to use

this.modelFor('map').trail = value;

I get that error

Uncaught Error: Assertion Failed: You must use Ember.set() to set the trail property (of [object Object]) to <nested-component@model:mtg-trail::ember617:kvdpo>.




Aucun commentaire:

Enregistrer un commentaire