model - Using ember-data to perform a UI update with user defined parameters -


i working on ember.js app, using ember-data restadapter communicate service.

i defined needed ember-data models , seems work fine, not quite sure, if going in right direction - going "is solution alright?"-question.

our service api provides method records limited requested time frame - rest request parameters this:

{ from: ..., to: ... } 

the user of ui should able select time frame , ui should update data within requested time frame.

there no write operations - read-only ui.

here current solution:

i defined route class provides model request result , arraycontroller serves ui.

route class code:

mymodelroute = ember.route.extend     model: ->         # calling controller required parameters initial         # model setup - doesn't feel right too, want keep         # time frame parameters json request @ 1 position (controller)...         controller = @controllerfor('my_models')         # fromdate , todate controller         mymodel.find({from: fromdate, to: todate}) 

arraycontroller code:

mymodelcontroller = ember.arraycontroller.extend     updatemymodels: ->          # ... boring code fromdate , todate ...          # overwriting content property set         # route's model property seems nasty...         mymodels = mymodel.find({from: fromdate, to: todate})         mymodels.one('didload', =>             @set('content', mymodels)          ) 

my view provides 2 date pickers, allowing user specify time frame wants see (fromdate , todate in sample code).

whenever user selects new time frame, 2 observed variables on controller updated cause new request server user requested time frame (updatemymodels() method in sample).

so, here point: can see, updating 'content' property of arraycontroller within controller's updatemymodels() method bound ui timeframe properties - totally ignoring provided route's model. model property on route exists "initialize" controller seems bit odd...

everything works fine, wondering if there better / right way that?

if should use model provided route instead of controller property: there way communicate route's model controller (i sure there way ;-) ), , more important: how can reload current route controller? transitionto() method right way?

thanks in advance!

i having similar issue , ended removing route object. routes make sense if accessing url params. since mymodelroute not access params remove it. can still initialize controller inside 'init' method.

things different if encoding query inside path… "/my_model/fromdate/todate" or something. didn't need though. handling in controller.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -