dojo: Set ValidationTextBox to blur

给你一囗甜甜゛ 提交于 2019-12-24 10:58:55

问题


I can't make ValidationTextBox to lose focus and I can't see the method blur() either.

How can I make it lose focus?


回答1:


The blur() method works on dom nodes. A widget is often backed by an html template. If you look at dijit/form/templates/ValidationTextBox.html, you will see that there is a dom node which has a dojoAttachPoint containing "focusNode". Here is the code of the template on dojo 1.7, for reference :

<div class="dijit dijitReset dijitInlineTable dijitLeft"
id="widget_${id}" role="presentation"
><div class='dijitReset dijitValidationContainer'
    ><input class="dijitReset dijitInputField dijitValidationIcon dijitValidationInner" value="&#935; " type="text" tabIndex="-1" readonly="readonly" role="presentation"
/></div
><div class="dijitReset dijitInputField dijitInputContainer"
    ><input class="dijitReset dijitInputInner" dojoAttachPoint='textbox,focusNode' autocomplete="off"
        ${!nameAttrSetting} type='${type}'
/></div

You can achieve your blur trigger through a direct reference of the node referenced in the template as "focusNode" by doing something like :

dijit.byId("myValidationTextBoxId").focusNode.blur();



回答2:


You have to override the functionality of the class ValidationtextBox.js. By default its is always invoked on the onkeypress event.



来源:https://stackoverflow.com/questions/8801039/dojo-set-validationtextbox-to-blur

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!