0

我们有一个 dojo 过滤选择对象,但必须通过 jquery 进行验证。现在的问题是

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

value 只返回所选选项的文本而不是所选值...似乎 dojo 对原始 Dom 对象进行了一些更改,因为 dojo 选择对象被标识为input#filteringSelectId.dijitReset

那么如何通过jQuery获取dojo的filteringSelect值而不是选项文本呢?可行吗?

4

1 回答 1

2

如果您查看过滤选择创建的实际 HTML,它将看起来像这样(取自dojo 的参考文档

<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');
于 2013-05-15T14:29:22.390 回答