Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen I click {{#linkTo}} and set the object in ember.js
    text
    copied!<pre><code> App = Ember.Application.create({ currentProject: 21 }); </code></pre> <p>The <code>App.currentProject</code> default is 21, and when I click the {{#linkTo}}, I want to set the <code>:project_id</code> in the <code>App.currentProject</code> .</p> <p>Route:</p> <pre><code>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); } }) </code></pre> <p>Templates:</p> <pre><code>{{#each controller}} &lt;div class="panel"&gt; {{#linkTo 'tasks' this}} //click this linkTo, render to project/:project_id/tasks URL and set the App.currentProject to the :project_id at the sametime &lt;div class="top"&gt;&lt;i class="batch-big b-code"&gt;&lt;/i&gt; &lt;h6&gt;{{title}}&lt;/h6&gt; &lt;/div&gt; {{/linkTo}} &lt;/div&gt; {{else}} &lt;div&gt;There are no Projects.&lt;/div&gt; {{/each}} </code></pre> <p>I don't know where <code>App.currentProject</code> set to <code>project_id</code>, in the route :</p> <pre><code>App.TasksRoute = Ember.Route.extend({ model: function(params){ App.set('currentProject', params.project_id); //I add the code to here,but it did not work return App.Project.find(params.project_id); }, setupController: function(controller, model) { controller.set('content', model.tasks); } }) </code></pre> <p>The template {{#linkTo}}, I did not know how to set the action.</p> <p>Version information</p> <ul> <li>Require: 2.1.4</li> <li>jQuery: v1.9.1 </li> <li>Ember: v1.0.0-rc.1 </li> <li>Handlebars: 1.0.0-rc.3</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload