当用户点击页面('workflow_editor.hbs')的主要内容(‘workflow_editor.hbs’)中的一个标题时,我希望在一个名为‘.hbs _editor_sidebar.hbs’的侧边栏编辑器文件中呈现‘we-is-app-complete.hbs e.hbs’,但我不希望改变当前的路由。
我尝试了{{ action on="focusIn }},但是我没有在workflow_editor_controller.js中定义一个函数来放在'action‘和'on=’之间。让我们将这个未定义的函数称为'renderIsAppCompleteTemplate:‘。
如果选择了不同的标题,侧边栏将隐藏‘we- is -app- template e.hbs’并呈现一个新模板,但在本例中,我们将只关注‘we-is-app-template e.hbs’。
在‘we-is-app-complete.hbs e.hbs’中
<h2> This is the code that I want to render.</h2>在“workflow_editor_sidebar.hbs”中
{{#if 'renderIsAppCompleteTemplate}
{{render 'we-is-app-complete.hbs}}
{{/if}}在'workflow_editor.hbs‘== '/workflow_editor/new’
<div {{ action 'renderIsAppCompleteTemplate' on="focusIn" }} class="fees-container collapsible">
<div class="arrow-nav collapsibleHeader fees-edit-selection">
<h2>Permit Fees
<h4 class="inline-block"> ((#)) of Calculations</h4>
</h2>
<img src="images/menu.png" class="menu-icon" id="m1">
</div>
</div>在“workflow_editor_controller.js”中
VpcYeoman.WorkflowEditorController = Ember.ObjectController.extend({
renderisAppCompleteTemplate: function() {
*/ nothing yet */
})请随时建议解决此问题的替代方法或更有效的方法。
编辑:我做了一些类似的事情,根据当前的渲染边栏模板。如果它能激发任何灵感,下面是代码。
对于控制器
showRecordBasedOnRoute: function(){
var curPath =this.get('currentPath');
if(curPath == 'application'){
return false;
} else if (curPath == 'record'){
return true;
} //other things
}.property('currentPath'),&&
{{#if showRecordBasedOnRoute}}
{{render 'record-sidebar'}}
{{/if}} 发布于 2014-01-09 09:15:27
遗憾的是,您一次只能有一条活动路由。我也有同样的问题。有一个实验版本,让您使用具有独立路由的子路由器,但这不值得麻烦。
你目前所做的一切都很好。但是,您需要在actions对象中定义操作。
VpcYeoman.WorkflowEditorController = Ember.ObjectController.extend({
actions: {
renderisAppCompleteTemplate: function() {
*/ nothing yet */
}
}
})https://stackoverflow.com/questions/21005550
复制相似问题