2013-01-17 77 views
0

嗨我已經設置了dijit/select,但問題是我不確定在選擇時捕獲並顯示值。我看過dijit/form select,dojo.query和dojo/on。但我仍然無法提出解決方案。你能提供建議嗎?由於道場1.8:選擇時的價值指標

var select_Card = new Select 
(
{name:'select_PCBA', 
    options: 
     [ 
    {label:"<span id='NotinUse'><b>&nbsp&nbsp&nbsp. . .</b></span>", value:"", selected:true}, 
{label:"<span id='NotinUse'><b>&nbsp&nbspA Card</b></span>", value:"a" }, 
{label:"<span id='inUse'><b>&nbsp&nbspB Card</b></span>", value:"b"}, 
{label:"<span id='NotinUse'><b>&nbsp&nbspC Card</b></span>", value:"c"}, 
{label:"<span id='NotinUse'><b>&nbsp&nbspD Card</b></span>", value:"d"}, 
{label:"<span id='NotinUse'><b>&nbsp&nbspE Card</b></span>", value:"e"}, 
     ], style:{width:'150px'} 
},"select_Card"); 

    var card = dom.byId('inUse'); 
on(card,'click', function(evt) 
{ 
    alert('Item selected is'+ card.value); 
    }); 

克萊門特

回答

0

widget的onChange事件是你想要的。

on(select_Card, 'change', function(newValue){ 
    alert(newValue); 
}); 

http://jsfiddle.net/cswing/udJuv/

+0

嗨克雷格。謝謝。你怎麼知道這些卡片,雖然我沒有把這些卡片放在這個代碼中?我很驚訝地看到你的jsfidder中的卡片,儘管我在這裏只寫了A到E.然而。謝謝。 – user1739825

+0

那個小提琴最初是爲你的其他問題建立的http://stackoverflow.com/questions/14334959/add-bold-and-font-to-dijit-form-select-programatically/14341385#comment19957526_14341385我剛剛加強它回答這個。 –

+0

哦,難怪....很抱歉,謝謝 – user1739825