PHPSpellCheck has a full JavaScript API that can be used at runtime to capture user events and modify spellchecker behaviour.

You can access your existing PHPSpellCheck AsYouType and SpellButton objects in JavaScript using their ID attribute as their JavaScript object name.

Example - Capturing the onDialogOpen Event

SourceCode:
<?php
	require "/phpspellcheck/include.php";	
	$mySpell = new SpellCheckButton();
	$mySpell->InstallationPath = "/phpspellcheck/";	 
	echo $mySpell->SpellImageButton();
?>	
	
<script type='text/javascript'>
	var mySpellObject = <?php echo ($mySpell->ID)?>;

	mySpellObject.onDialogOpen = function(){
		alert("onDialogOpen event fired")		
	}

</script>


Capturing the As-You-Type Events

As-You-Type user spelling events follow the exact same syntax...

SourceCode:
<?php

	$mySpell = new SpellAsYouType();
	$mySpell->InstallationPath = "/phpspellcheck/";	 
	echo $mySpell->Activate();
?>

<script type='text/javascript'>
var mySpellObject = <?php echo ($mySpell->ID)?>;
	mySpellObject.onChangeWord = function(){
			alert("onChangeWord event fired from content spellcheck")		
		}
</script>

Advanced JavaScript Development

Read the Javascript-AJAX-Spell-Check-APIObject Reference...

Events can apply to both as-you-type and in dialog spellchecking as needed:

  • onDialogOpen
  • onDialogComplete
  • onDialogCancel
  • onDialogClose
  • onChangeLanguage
  • onIgnore
  • onIgnoreAll
  • onChangeWord
  • onChangeAll
  • onLearnWord
  • onLearnAutoCorrect
  • onUpdateFields