This class allows you to provide spell checking for text. It uses Google to check if the text is correct and to get some suggestions. This is done by a PHP script that uses cURL to get some xml and translates it to JSON, so we can use Request.JSON for our client-side. That is where Request.SpellCheck is build on. Request.SpellCheck will give you an array in the onSuccess event that you can use. (for mark-up things)
var spell = new Request.SpellCheck([options]);
This class extends Request.JSON, so you can use all Request.JSON stuff you already know.
var spell = new Request.SpellCheck([options]);
All the options of Request.JSON
All the events you know from Request.JSON
Fired when the request completes. This overrides the signature of the Request.JSON success event.
onSuccess(suggestions, responseJSON, responseText, text)
This is the method you use this method to check a text.
spell.checkspell('Testng ths spelcheckr out.');
You can use this method to set the language to another language.
spell.setLang('nl');
window.addEvent('domready', function() { var result = document.id('result'); var spell = new Request.SpellCheck({ url: '../Source/spellcheck.php', onSuccess: function(suggestions,data,response,text){ result.empty(); $each(suggestions,function(sug){ new Element('span',{ 'class': sug.valid ? '' : 'error', text: sug.text }).inject(result); if(!sug.valid){ new Element('span',{ 'class': 'suggestions', text: '('+sug.suggestions.join(', ')+')' }).inject(result); } }); } }); spell.checkspell('Testng ths spelcheckr out.'); });
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus