In ExtJs, how to insert a fixed string at caret position in a TextArea?

蓝咒 提交于 2020-01-04 04:20:50

问题


This question probably is asked in other framework, not sure if there is one on ExtJs, which I am new to. I wonder whether there is a simple example with a TextArea and a button. When the button is pressed, a fixed string "???" is inserted at the cursor in the TextArea.

Thanks in advance.


回答1:


You can actually do this straight from the DOM, using textareas selectionStart attribute to find the caret position.

So you could do something along the lines of

textArea.value = textArea.value.substring(0, selectionStart)+'???'+textArea.value.substring(selectionStart);

Here is a jsfiddle demonstrating this using a combination of Ext.get and Ext.getDom to select and modify the elements.



来源:https://stackoverflow.com/questions/13774153/in-extjs-how-to-insert-a-fixed-string-at-caret-position-in-a-textarea

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