2013-05-15 39 views
0

我們有一個dojo過濾select對象,但必須通過jquery進行驗證。現在的問題是

var value= j("#filteringSelectId").val(); 

值僅返回選定的選項,而不是選擇的值的文字...似乎道場已經做了一些修改原來的DOM對象,作爲道場選擇對象被確定爲input#filteringSelectId.dijitReset

那麼我怎麼能通過jQuery獲得dojo filteringSelect值而不是選項文本?它可行嗎?

+2

看看它的呈現html ... – karaxuna

回答

2

如果你看一下實際的HTML過濾選擇創建,它會是這個樣子(從dojo's reference docs拍攝)

<div class="dijit dijitReset dijitInline dijitLeft dijitTextBox dijitComboBox dijitValidationTextBox" id="widget_stateSelect" role="combobox" aria-haspopup="true" data-dojo-attach-point="_popupStateNode" widgetid="stateSelect"> 
    <div class="dijitReset dijitRight dijitButtonNode dijitArrowButton dijitDownArrowButton dijitArrowButtonContainer" data-dojo-attach-point="_buttonNode" role="presentation" style=""> 
     <input class="dijitReset dijitInputField dijitArrowButtonInner" value="&#9660; " type="text" tabindex="-1" readonly="readonly" role="button presentation" aria-hidden="true" /> 
    </div> 
    <div class="dijitReset dijitValidationContainer"> 
     <input class="dijitReset dijitInputField dijitValidationIcon dijitValidationInner" value="&Chi; " type="text" tabindex="-1" readonly="readonly" role="presentation" /> 
    </div> 
    <div class="dijitReset dijitInputField dijitInputContainer"> 
     <input class="dijitReset dijitInputInner" type="text" autocomplete="off" data-dojo-attach-point="textbox,focusNode" role="textbox" aria-required="true" tabindex="0" id="stateSelect" value="California" /> 
     <input type="hidden" name="state" value="CA" /> 
    </div> 
</div> 

基於這些信息,你也許可以建立像一個選擇:

$('#filteringSelectId .dijitReset input[type="hidden"]').val() 

如果你只需要得到JavaScript中的值(我不能說我熟悉的jQuery驗證),你可以不喜歡

dijit.byId('widgetId').get('value'); 
+0

這真棒,最好的答案! – Dreamer