问题从Dijit / form / Select获取selectedIndex时

时间:2014-04-30 06:16:32

标签: dojo

我正在jsp页面上将Dojo的1.4升级到1.8.Below是代码片段

<div data-dojo-type="dijit/layout/BorderContainer" gutters="false"
                            style="margin-left: 0px; margin-top: 2px; margin-bottom: 2px">
                            <select name="<%=inputName%>"
                                id="XX.AddNewDocument.<%=panelName%>.<%=inputName%>"
                                jsId="XX.AddNewDocument.<%=panelName%>.<%=inputName%>"
                                onKeyPress="handleSearchPanelInputKeyDown"
                                onBlur="handleSearchPanelInputLostFocus"
                                onFocus="handleSearchPanelInputGetFocus"
                                onChange="onChangeLinkedField(this)"
                                <%
            String dataSourceUrl = inputConfig.getPicklistUrl();
                                        System.out.println("Jaya6 dataSourceUrl "+dataSourceUrl);
            boolean hasDataSource = dataSourceUrl != null && dataSourceUrl.length() > 0;
            if (hasDataSource) {
                %>
                                store="<%=uiModel.getInputDataStoreId(panelName, inputName)%>"
                                <%
            }
            if (inputConfig.isHidden()) {
                %>
                                style="visibility: hidden;" <%
            }
                %>
                                data-dojo-type="dijit/form/Select" inputWidth="168" 
                                style="width:186px;margin:2px;" maxHeight="200"
                                sortByLabel=true>
                                <%

on&#34; onChange&#34;事件onChangeLinkedField函数在另一个JSP中调用:

this.onChangeLinkedField = function (srcField) {

    alert(srcField.selectedIndex);
     console.log(srcField.name + " changed by user");
    this.changeLinkedField(srcField);
}

但是srcField.selectedIndex返回null。我想得到选定值的索引

请帮助获得相同的

先谢谢

1 个答案:

答案 0 :(得分:0)

嘿,你可以试试这个替换

this.onChangeLinkedField = function (srcField) {

    this.store.get(srcField).then(
       function(response){
            console.log(response); // result object{} contain id and data
    });
    this.changeLinkedField(srcField);
}

我希望这会对你有所帮助。 感谢