PDA

View Full Version : JSpell with TinyMCE and input text fields


Light
3rd March 2008, 02:39 PM
I'm having a problem trying to get the spell check to attach to both a TinyMCE textarea and other input type=text fields on the web page. I keep getting a "Exception thrown and not caught" error.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" type="text/javascript" src="../tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="JavaScript" type="text/javascript" src="/jspellEvolution/jspellSettings.js" charset="ISO-8859-1"></script>
<script language="JavaScript" type="text/javascript" src="/jspellEvolution/jspellEvolution.js" charset="ISO-8859-1"></script>
<script language="javascript" type="text/javascript">
jspellServerPath="/jspellEvolution/jspell_proxy.asp"; // specifies the URL to the JSpell Evolution spell check server
function postTinyMCEInit() {
setTimeout(jspellInit,500);
}
tinyMCE.init({
mode : "textareas",
oninit : "postTinyMCEInit",
theme : "simple"
});

function getSpellCheckArray() {
var fieldsToCheck=new Array();
// Use DOM Element IDs to specify fields to spell check
fieldsToCheck[fieldsToCheck.length]=[document,"inputtext"];
fieldsToCheck[fieldsToCheck.length]=[document,"txtarea"];
return fieldsToCheck;
}
</script>
</head>

<body>

<form name="form1" method="post" action="">
Some input:
<input type="text" name="inputtext" />
<br />
Some textarea:<br />
<textarea name="txtarea" rows="10" cols="50"></textarea>
</form>

</body>
</html>

hamiltd1
19th June 2008, 05:13 PM
I know I'm replying to an older post, but whenever you see "Exception thrown and not caught" with JSpell, it really only means one thing, JSpell can't find the element you defined in fieldsToCheck[fieldsToCheck.length] = [document,"inputtext"];

If this ever happens to you, the easiest way is to view the page in FireFox and use the DOM Inspector to see what the ID is for the field. Most likely you will find that instead of using "inputtext", you need to use "form1:inputtext"

Debugbar from Internet Explorer also works really well for this purpose. Once you know that full ID, use it.

I hope this helps someone else as well, it is NOT documented at all and the message is completely wrong. It took me a lot of trial and error to finally figure this out.

There really needs to be a list of the common exceptions / alerts that can occur and what they really mean. It is only fair considering the Javascript is encrypted and we can't figure the meaning out ourselves very easily.

zooomer
31st July 2008, 03:23 AM
You need to have id="inputtext" in the input tag instead of or in addition to name="inputtext". It will look for the id, not the name.