javascript - backbone-forms: style options of a select field? -
i using backbone-forms , i'm wondering, whether possible add styles options (<option>
) in select field. app quite complex snippet here:
this.schema = { xname : { title : i18n.t('x.name') + " " + i18n.t('x.name-msg'), type : 'text', validators : [ { type : 'required', message : i18n.t('x.name-required-msg') }, { type : 'regexp', regexp : /.{3,}/, message : i18n.t('x.name-tooshort-msg') } ], }, */ ... */ selecty : { title : i18n.t('y.project'), type : 'select', options : this.getsomeoptions() //is defined , works well!! } /* , on ... */
now quite obvious, cannot add style attribute selecty in order differntiate between it's options ans style them. e.g. (from backbone-forms docs):
fieldattrs
a map of attributes add field, e.g. { style: 'background: red', title: 'tooltip help' }
in our (or any) schema can define name
, label
options. see other possibility using jquery in dirty hack when/on rendering (or, more specific: showing) form field? suggestion appreciated.
there isn't built-in way of doing want create custom editor extends select , overrides _arraytohtml method, e.g.:
var customeditor = backbone.form.editors.select.extend({ arraytohtml: function(array) { ... } });
see https://github.com/powmedia/backbone-forms#custom-editors
Comments
Post a Comment