Browse files

MINOR Added destroy() method to jQuery.changetracker plugin

  • Loading branch information...
1 parent 6c1f799 commit 0b6d45356ebb9a55f07eb2834e0aab19227f4b2a @chillu chillu committed Jun 13, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 admin/javascript/jquery-changetracker/lib/jquery.changetracker.js
View
12 admin/javascript/jquery-changetracker/lib/jquery.changetracker.js
@@ -67,15 +67,23 @@
// setup original values
var fields = this.getFields();
- fields.filter(':radio,:checkbox').bind('click', onchange);
- fields.not(':radio,:checkbox').bind('change', onchange);
+ fields.filter(':radio,:checkbox').bind('click.changetracker', onchange);
+ fields.not(':radio,:checkbox').bind('change.changetracker', onchange);
fields.each(function() {
var origVal = $(this).is(':radio,:checkbox') ? self.find(':input[name=' + $(this).attr('name') + ']:checked').val() : $(this).val();
$(this).data('changetracker.origVal', origVal);
});
this.data('changetracker', true);
};
+
+ this.destroy = function() {
+ this.getFields()
+ .unbind('.changetracker')
+ .removeClass(options.changedCssClass)
+ .removeData('changetracker.origVal');
+ this.removeData('changetracker');
+ };
/**
* Reset change state of all form fields and the form itself.

0 comments on commit 0b6d453

Please sign in to comment.