dojo 自动文本框 select

dojo automatic textbox select

Dojo 新手在这里,我有一个对话框,在我 dialog.show() 之前,我想完全设置和 select 其中一个文本框。我试过 select() 不可用。作为扩展,我需要 select 在对话框启动后单击任何文本框时的整个文本框内容。我似乎无法绕过丢失的 select()。我该怎么做?

TextBox 上有一个 selectOnClick 属性应该可以帮助您:

<input data-dojo-type="dijit/form/TextBox" 
       data-dojo-props="selectOnClick:true"
       value="Everything is selected on click"/>

http://jsfiddle.net/inanutshellus/v97wgxLb/

如果您想以编程方式设置焦点和选择,您可以作弊并直接调用私有 _onFocus 方法。看起来你会传入字符串 "mouse",例如

myTextBox._onFocus("mouse");