javascript - How to reload correctly a route in Ember JS -



javascript - How to reload correctly a route in Ember JS -

i'm working latest release of ember js (rc1), , have architectural problem :

i have simple utilize case : list of users, , form add together users. router:

app.router.map(function () { this.resource('users', function () { this.route('new'); }); });

my routes:

app.usersroute = em.route.extend({ model:function () { homecoming app.user.findall(); } });

my controller:

app.usersnewcontroller = em.objectcontroller.extend({ saveuser:function () { //'content' contains user app.user.save(this.content); // here want reload list of users, doesn't work // application goes correctly url /users // doesn't phone call 'model' function this.transitiontoroute('users'); } });

as in above comment, when create new user, i'd redirect list of users (that part works) , reload user list calling 'model' method of route (that part doesn't).

i write method in userscontroller reload list, have duplication between usersroute , userscontroller.

can help me on problem ?

thanks

p.s. : here fiddle http://jsfiddle.net/vsxxj/

ember documentation on model hook:

"a hook can implement convert url model route."

so not think hook right case. think should utilize setupcontroller hook case. seek this:

app.usersroute = em.route.extend({ setupcontroller(controller){ controller.set("content", app.user.findall()); } });

javascript ember.js

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -