Monday, 15 July 2013

ember.js - How to get entrie from another controllers content and call self controller on missing -



ember.js - How to get entrie from another controllers content and call self controller on missing -

this code illustration: http://jsbin.com/uzapuy/1/edit

i want able access test url so: http://jsbin.com/uzapuy/1#/test/2 because entrie may nowadays in client side, want check first , if missing fetch server side. possible without ds.store?

in testroute, can not like:

app.testroute = ember.route.extend({ model: function(params) { // find controller has "fetch" method. var testcontroller = this.controllerfor('test'); // check if there's existing model id. var existingmodel = testcontroller.find('id', params.id); // determine if found model or not. if (existingmodel) { // if found existing model, can set model. homecoming existingmodel; } // otherwise we'll fetch server. homecoming testcontroller.fetch(params.id); } });

also, bear in mind in code, test variable undefined:

var tests = app.test.create({id: id, name: 'fetched ' + id}); self.set('content', test);

you're after tests, assume.

ember.js

No comments:

Post a Comment