view - When I click {{#linkTo}} and set the object in ember.js -
app = ember.application.create({ currentproject: 21 });
the app.currentproject
default 21, , when click {{#linkto}}, want set :project_id
in app.currentproject
.
route:
app.router.map(function() { this.resource('project', { path: '/project/:project_id' }, function(){ this.resource('tasks', function(){ this.route('new'); }); }) }); app.tasksroute = ember.route.extend({ model: function(params){ return app.project.find(params.project_id); }, setupcontroller: function(controller, model) { controller.set('content', model.tasks); } })
templates:
{{#each controller}} <div class="panel"> {{#linkto 'tasks' this}} //click linkto, render project/:project_id/tasks url , set app.currentproject :project_id @ sametime <div class="top"><i class="batch-big b-code"></i> <h6>{{title}}</h6> </div> {{/linkto}} </div> {{else}} <div>there no projects.</div> {{/each}}
i don't know app.currentproject
set project_id
, in route :
app.tasksroute = ember.route.extend({ model: function(params){ app.set('currentproject', params.project_id); //i add code here,but did not work return app.project.find(params.project_id); }, setupcontroller: function(controller, model) { controller.set('content', model.tasks); } })
the template {{#linkto}}, did not know how set action.
version information
- require: 2.1.4
- jquery: v1.9.1
- ember: v1.0.0-rc.1
- handlebars: 1.0.0-rc.3
Comments
Post a Comment