dojo:将ValidationTextBox设置为模糊 [英] dojo: Set ValidationTextBox to blur
问题描述
我无法使 ValidationTextBox
失去焦点,我看不到方法 blur()
I can't make ValidationTextBox
to lose focus and I can't see the method blur()
either.
如何让它失去焦点?
推荐答案
blur()方法适用于dom节点。窗口小部件通常由html模板支持。如果您查看dijit / form / templates / ValidationTextBox.html,您将看到有一个dom节点包含一个包含focusNode的dojoAttachPoint。以下是dojo 1.7上的模板代码,供参考:
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="Χ " 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
您可以通过直接引用模板中引用的节点focusNode来实现模糊触发,方法如下:
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();
这篇关于dojo:将ValidationTextBox设置为模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!