我希望在出现带有textarea的新视图时,将光标设置为带有id="mytextarea"
的textarea。
似乎.focus()应该可以工作,但事实并非如此。为什么呢?
console.log('this message is displayed');//displayed in console
Ext.getCmp('mytextarea').focus();//nothing happens at the same time
这就是我在Chrome中所拥有的:
<div class="x-container x-field-textarea x-field x-label-align-left x-form-label-nowrap x-empty" id="mytextarea">
<div class="x-form-label" id="ext-element-127" style="width: 30% !important;">
<span id="ext-element-128"></span>
</div>
<div class="x-component-outer" id="ext-element-126">
<div class="x-unsized x-field-input sencha-clear-icon" id="ext-textareainput-1">
<textarea id="ext-element-129" class="x-input-el x-form-field x-input-text" type="text" autocapitalize="off" placeholder="Type here...">
</textarea>
<div class="x-field-mask" id="ext-element-130" style="display: none !important;">
</div>
<div class="x-clear-icon" id="ext-element-131">
</div>
</div>
</div>
</div>
谢谢。
答案 0 :(得分:0)
我需要将光标移动到Texarea的末尾。使用SenchaTouch 2.3.0 / iOS。我做了它将焦点设置到文本字段并设置新的值soo。当我打开弹出窗口时 - textfeld会在文本末尾集中注意力和插入位置。
var textarea = document.getElementById('note'),
note = textarea.getValue();
textarea.focus();
textarea.setValue('');//without this nothing happend
textarea.setValue(note);