Hi everyone I'm trying to write a function that will pass through the id of a clicked element, and then use that id for spellchecking the word that's been clicked on. However, although this seems to work, when i click on another word, it returns the previous corrected word rather than the new one - as if it's storing the same data all the time. I was advised to unbind the event but that doesn't seem to work...
Here is my code - but let me quickly explain. First off, there is a div with text in which has several "clickable" words which can be altered by the user by means of a pop up tooltip with input box. If the user types a word in and hits "save", the spell check will activate (i.e. checkWordSpelling). I'm firstly unbinding the click event, and then rebinding it for the next word - and although the correct id is detected, the word that it's supposed to place there after correcting is always the same one (i.e. the first one that was corrected): $('#'+tooltipsavebtn).unbind('click'); $('#'+tooltipsavebtn).bind("click",{theid: id },function(e) { var newval = $('#'+tooltipinput).val(); setProfileText(id,newval,tooltipid,targetid); spellchecked = false; pickedfromlist = false; checkWordSpelling(e.data.theid); var exists = false; for(i=0;i<len;i++){ if (words[id][1][i] == newval){ exists = true; } } if(exists == false){ if(len<6){ words[id][1].push(newval); }else{ words[id][1].splice(0,1,newval); userwords[id][1].splice(0,1,newval); } } $('#'+tooltipsavebtn).fadeOut('slow'); }); My spellcheck function initiates a dialog with a callback function: function checkWordSpelling(id) { // opens and performs the spell check var theid = "#"+id; var $spellcheckthis = $(theid); var thetext = $spellcheckthis.text(); var callback = function() { var correctedtext = $('#correctedText').text(); $spellcheckthis.text(correctedtext); } var spellcheck = JQSpellCheckDialog.create({text : thetext}, callback, SpellCheckOptions); spellcheck.open(); } the call back will take the contents of the dialog with the corrected word and place it in place of the user entered word - at least, that's what it's SUPPOSED to do...but like I say it seems to keep replacing it with the first word all the time... I hope I am explaining this ok...but if anyone needs more description let me know. I would link to an example but due to data protection from my company, it's a little difficult but if it's required for anyone to actually be able to help me I'll see what I can do. Thanks in advance, Mike