ember.js - Ember CLI path based on server response -
i'm developing substantial ember app, using ember cli, , i'm struggling few aspects of it.
what want is:
- show dropdown list of options
- when user picks option, post choice backend
- the response server contains data based on user picked in dropdown. after getting server response want transition new route path ends 1 of values returned server.
for example:
/path/to/dropdown
-- shows dropdown user pick from, posted backend. backend responds with, amongst other data:
slug: <stringvalue>
this transitions to: /path/to/slug
-- slug
<stringvalue>
so far i've got 1 & 2 above working, can't figure out how make step 3 work. i've tried using serialize function in /path/to/slug
route , /path/to/dropdown
controller, returns undefined
.
the ajax call server, based on user's dropdown choice, happens in /path/to/dropdown
controller.
i've set router as:
this.route('options', { path : ':slug' });
would great if point me in right direction; hope example clear enough let me know if not.
thanks.
to honest don't understand why use this.route('options', { path : ':slug' });
. created route possible options (in fact, urls of form /anything
), that's not want.
i think solution this.transitiontoroute(url_string)
available in controller. check api example there. before should declare routes in router , create operating files them, of course.
if don't want create route each possible slug, route pretty excellent, @ least i'd consider add 1 more path section. example, this.route('options', { path : '/slugs/:slug' });
. after can run transitionto
, pass data (in format) it. data assigned route model , able use in slugroute (and slugcontroller, if didn't redefined setupcontroler
method) this.get('model')
variable.
if want run transition view, firstly need obtain controller , send special command it.
Comments
Post a Comment