在 w2ui 1.5 中,您可以使用$jQueryElement.w2field()
来访问 w2fild 对象 - 然后对其进行操作。
例子:
var field = $("#my_input").w2field();
field.options.items = ["my", "new", "items"];
// optionally: pre-select first item
field.setIndex(0);
// if you do NOT use "setIndex" you need to call "refresh" yourself!
// field.refresh();
注意:setIndex()
内部调用refresh()
- 如上所述,在这种情况下您不需要自己调用刷新。
如果您想完全清除/清空您的字段,您可以调用field.reset()
.
编辑:在澄清它是关于一个表单字段之后:
// Note: ``this`` refers to the w2form
// ``field[8]`` refers to a field of type "select"
this.fields[8].options.items = ["my", "new", "items"];
this.record = {
field_select: 'new'
};
this.refresh();