Ember.Select的奇怪问题
Strange Issue with Ember.Select
我对Ember有一个非常奇怪的问题。选择,我在两个不同的模板中使用相同的Ember.Select
,并且两者都由两个不同控制器支持。但我只得到一个Ember.Select.中的团队列表
工作的第一个地方是:
<script type="text/x-handlebars" data-template-name="twoduser">
<!-- more Info-->
<div class="span3 pull-left" id="moreinfo2">
<div class="row">
<b>Full Name:</b> {{firstname}} {{lastname}}
<br/>
<b>Email:</b> {{email}}
<br/>
<b>Address:</b> {{address}}, {{city}}, {{state}}, {{country}}
<!--<br />
City:
<br/>
State/Province:
<br/>
Country:
<br/> -->
<br/>
<b>Phone:</b> {{phone}}
<br/>
<b>Experience:</b> {{experience}}
<br/>
<b>Designation:</b> {{designation}}
<br>
{{view Ember.Select
contentBinding="team"
optionValuePath="content.team_name"
optionLabelPath="content.team_name"
selectionBinding="selectedTeam"
prompt="Please Select a Team"}}
<button class="btn" {{action 'addToTeam' }}>Add To Team</button>
</div>
</div>
</script>
对应控制器:
App.TwoduserController = Ember.ObjectController.extend({
selectedTeam : null,
team : function (){
var teams = [];
$.ajax({
type : "GET",
url : "http://pioneerdev.us/users/getTeamNames",
success : function (data){
for (var i = 0; i < data.teams.length; i ++){
var teamNames = data.teams[i];
teams.pushObject(teamNames);
}
}
});
return teams;
}.property(),
});
不工作的第二个地方:
<script type="text/x-handlebars" id="teammembers">
<div class="row-fluid">
<div class="span3 offset3">
<div class="row-fluid">
<div class="span12">
<h4>Your Team Members</h4>
{{view Ember.Select
contentBinding="team"
optionValuePath="content.team_name"
optionLabelPath="content.team_name"
selectionBinding="selectedTeam"
prompt="Please Select a Team"}}
<ul>
<li>
{{#each item in arrangedContent}}
{{#link-to 'teammemberdetail' item}}{{item.firstname}}, {{item.team_name}}{{/link-to}}
<br>
{{else}}
<p><b>Nothing there</b></p>
{{/each}}
</li>
</ul>
<button class="btn"
{{action 'generate'}}>Get Team Members PDFs</button>
</div>
</div>
<div class="row">
<div class="span12 offset5">{{outlet}}</div>
</div>
</div>
</div>
</script>
对应控制器:
App.TeammembersController = Ember.ObjectController.extend({
selectedTeam : null,
team : function (){
var teams = [];
$.ajax({
type : "GET",
url : "http://pioneerdev.us/users/getTeamNames",
success : function (data){
for (var i = 0; i < data.teams.length; i ++){
var teamNames = data.teams[i];
teams.pushObject(teamNames);
}
}
});
return teams;
}.property(),
});
我在后面的那张名单上看到了名字。为什么会发生这种情况?
您应该使用Route
从后端检索数据,并在控制器中进行设置(请参阅有关成员路由的指南)。
那么在optionValueBinding
和optionLabelBinding
中不应该有路径的content.
部分。
最后,您应该更好地使用Ember中的{{select}}
Handlebars辅助对象。
相关文章:
- 在具有CONTENT标记的自定义元素中使用SELECT标记时出现问题
- Ember.Select的奇怪问题
- 寻找 Web 组件来解决这个问题(可能是 SELECT 或不知道)
- Select上通过Ajax将Javascript变量传递到PHP文件中的问题
- 使用jquery select all选项发出问题
- 使用Angular.js和PHP在select下拉列表中获取问题
- 使用jquery清除select字段,但呈现问题
- HTML & lt; select>焦点问题:使用Firefox需要2次点击来选择一个<选项>
- select .js关于无结果插件和允许默认链接行为的问题
- AJAX和Select的问题
- 在select元素上使用jQuery更改函数时出现问题
- & lt;销售:select>使用默认选项为空时,下拉问题
- 在SELECT字段中动态加载内容的问题[ANGULAR JS]
- Angular js中ng- select的问题
- AngularJS的ng-select和ng-switch-when问题
- Javascript表单验证问题(<SELECT>标记)
- 使用按钮时select中的AngularJS验证问题,但使用跨度时没有
- 关于使用jQuery连接两个Select Options val()的问题
- sqlite中select查询的循环问题
- 基于SELECT选项显示一个元素和隐藏其他元素时出现问题