javascript - How to use Ember query parameters with beforeModel and select? -
demo: http://jsbin.com/zexopa/1/edit?html,js,output
i use query parameters in application. , queryparameters 'name' , 'category'.
the 'name' parameter used in select , 'category' uses input, there wrong select 'name' if set default null.
if change 'name', 'name' undefined in url.
route:
app.indexroute = ember.route.extend({ beforemodel: function() { this.controllerfor('index').set('products', [1,2,3]); }, model: function() { return [{'is_active':false, 'name':'one'}, {'is_active':false, 'name':'two'}, {'is_active':false, 'name':'three'}, {'is_active':false, 'name':'four'},{'is_active':false, 'name':'five'}]; }, actions: { queryparamsdidchange: function() { this.refresh(); } } }); controller:
app.indexcontroller = ember.controller.extend({ queryparams: ['name', 'category'], name: null, category: null }); template:
<script type="text/x-handlebars"> <h2>welcome ember.js</h2> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="index"> {{view "select" content=products value=name prompt="all"}} {{input type="text" value=category class="form-control"}} <ul> {{#each model |item|}} <li>{{item.name}}</li> {{/each}} </ul> </script> can check happens application?
query params must string binded. input works, value string object. in name array provided integer. unfortunately, have not found mention in docs, can see working demo here: http://jsbin.com/lixili/1/edit?html,js,output
if can give tip code:
beforemodelnot place setting controller properties, insetupcontrollermethod in jsbin provided- you did not defined query params in route, , rid of
queryparamsdidchange
hope helped!
Comments
Post a Comment