获取dojo中的复选框,使用on()方法 [英] Get value of checkbox in dojo, with on() method
本文介绍了获取dojo中的复选框,使用on()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用dojo 1.9,我试图访问不像文档示例中的复选框的值:
Using dojo 1.9, I'm trying to access the value of a checkbox not like in the example in the docs:
require(["dijit/form/CheckBox", "dojo/domReady!"], function(CheckBox){
var checkBox = new CheckBox({
name: "checkBox",
value: "agreed",
checked: false,
onChange: function(b){ alert('onChange called with parameter = ' + b + ', and widget value = ' + this.get('value') ); }
}, "checkBox");
});
,但将onChange事件移动到:
but by moving onChange event to:
query('#checkBox').on('change', function(){
var value = query(this).attr('value');
});
或类似的东西。我只想从on()方法访问它。但是我每次都得到相同的值 - 复选框被选中。任何想法?
or anything similar. I just want to access it from on() method. But I get the same value every time - checkbox is checked. Any ideas?
推荐答案
再次,我犯了同样的错误 - 应该是
And again I made the same mistake - it should be
registry.byId('checkBox').on('change', function(){
var value = this.value;
});
这篇关于获取dojo中的复选框,使用on()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文