尊敬的全部, 我已经以编程方式创建了一个新的Dojo按钮。我在我的一个自定义dojo类中这样做。在创建按钮时,我定义了一个onClick方法,该按钮在点击按钮时应该被调用。这个方法是类的一部分。我无法调用该方法,因为单击按钮时,“this
”的范围有所不同。有人可以帮我解决这个问题吗?以编程方式创建的Dojo按钮 - 范围问题
dojo.declare("CustomClass",null,{
createCustomButton:function(){
var button = new dijit.form.Button({onClick:function(){
removetrack();
testDataGrid.filter({status:"COMPLETED"});
}},"testButton1");
},
removetrack:function(){
//some logic
}
});
var customObj=new CustomClass();
customObj.createCustomButton();
我需要removetrack()
当我点击创建的按钮时调用方法。
从你的问题中不清楚你希望调用removetrack()的范围。我将在下面回答假设它是createCustomButton中的范围,但如果这是错误的,请澄清,我会看看是否我可以改变我的答案:) – mrtom 2011-03-03 12:01:10