I’m trying to use Brandon Aaron’s jquery spellchecker on an application I’m building.
https://github.com/brandonaaron/jquery-spellcheck#readme
I have set up the scripts and spell checking works as required on text areas which are part of the original page code. The spellcheck behaviour is associated with the relevant fields by way of the following code in the head of the document:
$('#test4').spellcheck({ events: 'keyup' });
When I try to add the same behaviour to a new form element eg:
var textarea = $("<textarea>");
textarea.spellcheck({ events: 'keyup' });
[NB Originally has $(“”).html() but have changed this in light of advice below and get same error]
I get the following error (from google chrome console)
Uncaught TypeError: Object # has no method ‘spellcheck’
I assume this is because the spellchecker has at some point associated a spellcheck method with each existing textarea but when I create a new one it doesn’t have this method? If so how do I associate the behaviour with the new element? Or am I on the wrong track?
Any help greatly appreciated.
Thanks,
Derek
The spellcheck script is a jQuery plugin, so it can only be run on a jQuery object, not on a DOM node or HTML string. Doing:
should work.