向Ember.js CollectionView添加选择行为的推荐方法是什么?
我基本上需要一个选择视图,但我想一些更具视觉吸引力的东西。我的直觉是我可以使用CollectionView来实现这一点,但我必须自己实现集合中元素的选择。这是惯例吗?有推荐的方法吗?有什么好的例子吗?假设我读对了,你只想要比基本选择列表更漂亮的东西。我不知道你的限制,但我真的很喜欢这些类型的东西 简单:试着根据你的喜好设计你的向Ember.js CollectionView添加选择行为的推荐方法是什么?,ember.js,Ember.js,我基本上需要一个选择视图,但我想一些更具视觉吸引力的东西。我的直觉是我可以使用CollectionView来实现这一点,但我必须自己实现集合中元素的选择。这是惯例吗?有推荐的方法吗?有什么好的例子吗?假设我读对了,你只想要比基本选择列表更漂亮的东西。我不知道你的限制,但我真的很喜欢这些类型的东西 简单:试着根据你的喜好设计你的 {{view Ember.Select contentBinding="App.content" optionLabelBinding="conten
{{view Ember.Select
contentBinding="App.content"
optionLabelBinding="content.text"
optionValueBinding="content.value"
selectionBinding="App.selection"
prompt="Choose ...."}}
如果您使用引导,类似这样的功能应该会起作用
<div class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
{{#each App.content}}
{{#view App.SelectView contentBinding="this"}}{{label}}{{/view}}
{{/each}}
</ul>
</div>
此链接是在Freenode上的#emberjs上向我推荐的:
它扩展了CollectionView以允许选择项目。实际上,我正在尝试构建一些miller列,因此选择不太正确。
App.SelectView = Em.View.extend({
tagName: 'li',
click:function(){
App.set('selected', this.get('content'));
// then hide the dropdown
}
});