我使用Backbone-forms来填充模型。我有一个带有骨干集合的选择字段作为方案中的选项。当此集合为空时,backbone-forms执行提取,但select的html显示为空。
当集合不为空时,总是将第一个选项作为值。
我希望第一次,当集合为空时,它也会默认显示第一个值。
class foo extends Backbone.Model
schema:
tag:
type: 'select'
options: new App.Collections.Tags发布于 2013-09-05 03:35:58
看看下面的例子
http://jsfiddle.net/evilcelery/dW2Qu/
var user = new User({
title: 'Mr',
name: 'Sterling Archer',
email: 'sterling@isis.com',
birthday: new Date(1978, 6, 12),
password: 'dangerzone',
notes: [
'Buy new turtleneck',
'Call Woodhouse',
'Buy booze'
]
});这些是默认值。
在您的示例中,您将使用类似于
var options = new App.Collection.Tags;
class foo extends Backbone.Model
schema:
tag:
type: 'select'
options: options
for (first in options) break;
var Foo = new foo({tag:first}); https://stackoverflow.com/questions/18302453
复制相似问题