Выделить часть текста в текстовой области extjs
Мне нужно выделить часть текста в текстовой области. Я видел, как это делается с помощью jquery, но я не могу использовать jquery, потому что приложение, над которым я работаю, уже использует extjs (текстовая область - лишь небольшая часть приложения). Это ссылка на пример jquery: http://www.strangeplanet.fr/work/jquery-highlighttextarea/ Я использую extjs 2.3.0
сообщение Extjs Textarea, я пытаюсь выделить текст в.
var message = new Ext.form.TextArea({
hideLabel: true,
id: 'smshl',
name : 'smshl',
emptyText: 'enter message here',
anchor: '90%',
allowBlank: false,
style:'overflow:hidden;style:margin:15px;',
height: 90,
minLength: 1,
minLengthText: 'You cannot send a blank text',
maxLength: userObj.smsLength,
maxLengthText: 'Sorry, Maximum length of message exceeded',
preventScrollbars: true,
enableKeyEvents: true,
listeners:{
keyup: function() {
this.highlightTextarea({
words: ["first word","another word"]
});
}
}
})
1 ответ
Решение
Я наконец понял это, все, что я должен был сделать, чтобы код, который я отправил в моем вопросе, работал, должен был заменить this.highlightTextarea with jQuery('#'+this.getId()).highlightTextarea
Таким образом, код становится:
var message = new Ext.form.TextArea({
hideLabel: true,
id: 'smshl',
name : 'smshl',
emptyText: 'enter message here',
anchor: '90%',
allowBlank: false,
style:'overflow:hidden;style:margin:15px;',
height: 90,
minLength: 1,
minLengthText: 'You cannot send a blank text',
maxLength: userObj.smsLength,
maxLengthText: 'Sorry, Maximum length of message exceeded',
preventScrollbars: true,
enableKeyEvents: true,
listeners:{
keyup: function() {
jQuery('#'+this.getId()).highlightTextarea.highlightTextarea({
words: ["first word","another word"]
});
}
}
})