lundi 29 février 2016

Form data saving in Ember.JS - using version 2.3

There is this post: "What's the right way of doing manual form data saving with Ember.js?", however, I am at a loss as to how to do this with Ember 2.3.

In the accepted answer to that question, we have this snippet:

App.IndexController = Ember.ObjectController.extend({
  proxy: {},
  setUnknownProperty: function(key, value) {
    console.log("Set the unknown property: " + key + " to: " + value); 
    this.proxy[key] = value;
    console.log(this.proxy);
  },
  flush: function() {
    for(var key in this.proxy) 
      this.set('model.'+key, this.proxy[key]);
  }
}); 

however, I do not have an "ObjectController" in my project. Running

ember generate controller test

gives me something that reads Ember.Controller.extend({ ... });, and not an ObjectController. Searching the 2.3 API, I cannot find ObjectController at all.

Inserting the snippet into the Ember.Controller.extend, where my various action methods are placed seems to not do the trick. The entire model disappears (no data), and adding data does not work either. Nothing happens, no errors, nothing. The methods are probably just not being called at all.

Any advice on "converting" this to 2.3 would be appreciated.




Aucun commentaire:

Enregistrer un commentaire