2010-09-20 25 views
0

我需要動態生成使用javascript和dojo的網頁UI。我需要聽產生小部件,以便用戶輸入做出反應,但我不能確定哪一個被改變......收聽動態數量的dojo小部件(dijits)

var combobox = new dijit.form.ComboBox(
{ 
    id: id, 
    store: dataStore, 
    onChange: dojo.hitch(this, this._comboChanged) 
}); 

在調用_comboChanged我得到了新的價值,但我也需要知道哪個組合被按下。可以有任意數量的組合,目前我將它們在創建後存儲在一個數組中。

回答

0

可以組合框本身傳遞給comboChanged方法:

var combobox = new dijit.form.ComboBox(
{ 
    id: id, 
    store: dataStore 
}); 
combobox.onChange = dojo.hitch(this, this._comboChanged, combobox);