jquery plugin to check if an element has been altered and stop the user if they leave, now better supports tinyMCE
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
jquery.tamper.js
jquery.tamper.min.js
readme.txt

readme.txt

/*
* jquery.tamper.js
*  v 1.4
*
* Initial Author
*  John Griffiths
* 
* Description
*  Simply watches an element for changes, if any encountered flips the tamper flag to true.
*  If the exit button is clicked and the tamper flag is set to true a dialog will appear warning 
*  the user they will lose their changes if they click OK.
*  Added "return this;" to support method chaining.
* 
* Params:
*  $(element)  : (required) element (textarea) to watch for changes
*  exitName    : (required) element (button) which classes as an exit when clicked
*  messageText : (optional) text to show in the alert dialog
*
* Example:
*  $(".title, .tinymce").tamper("#cancelButton", "Are you really sure?")
*
*  PLEASE NOTE: if an onclick event is present on the exit element it will clone it, remove it 
*  and append it so when the user click's ok it fires.
*  
*  v1.3 added support for TinyMCE to the 'tamper' function, if any elements have a class of 
*  .tinymce then it will use tinyMCE's .isDirty() method on-click for any changes.  if it returns 
*  true then data has changed.  Uses .each to support multiple tinyMCE controls on the page.
*
* Requires: jQuery v1.3+
* 
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html 
* 
*/