I need to highlight part of a text in a textarea. I have seen it done with jquery but I can't use jquery because the app I'm working on already uses extjs(the textarea is just a small part of the app). This is a link to the jquery sample: http://www.strangeplanet.fr/work/jquery-highlighttextarea/ I'm using extjs 2.3.0
message is the Extjs Textarea, I'm trying highlight text in.
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"]
});
}
}
})
I finally figured it out, all I had to do to make the code I posted in my question work was to replace this.highlightTextarea with jQuery('#'+this.getId()).highlightTextarea
So the code becomes:
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"]
});
}
}
})