Backbone-forms.js - 我可以在脚本中配置文本字段,还是在渲染后使用jQuery完成它?

时间:2013-01-29 18:10:42

标签: javascript backbone.js backbone-forms

嗨,我的脚本中有这个表格, 我可以解析脚本中的高度和宽度等选项值, 或者让我在通过该脚本渲染后用jQuery设计它?

var form1 = new Backbone.Form({
    schema: {
        country: { type: 'Select', options: ['UK', 'USA'] },
        city: { type: 'Select', options: cities.UK },
        message: { type: 'Text'}
    }
}).render();

1 个答案:

答案 0 :(得分:2)

您可以使用fieldAttrs属性为元素设置任何属性:

country: { 
  type: 'Select', 
  options: ['UK', 'USA'], 
  fieldAttrs: { style: "width: 400px; height: 30px;" } 
}

或者,您可以使用fieldClass属性提供CSS类,并使用常规样式表应用CSS规则:

country: { 
  type: 'Select', 
  options: ['UK', 'USA'], 
  fieldClass: 'country-select'
}

所有可用的架构属性都是documented here