MINOR Added destroy() method to jQuery.changetracker plugin

This commit is contained in:
Ingo Schommer 2012-06-13 23:15:13 +02:00
parent 6c1f7997a4
commit 0b6d45356e

View File

@ -67,8 +67,8 @@
// setup original values // setup original values
var fields = this.getFields(); var fields = this.getFields();
fields.filter(':radio,:checkbox').bind('click', onchange); fields.filter(':radio,:checkbox').bind('click.changetracker', onchange);
fields.not(':radio,:checkbox').bind('change', onchange); fields.not(':radio,:checkbox').bind('change.changetracker', onchange);
fields.each(function() { fields.each(function() {
var origVal = $(this).is(':radio,:checkbox') ? self.find(':input[name=' + $(this).attr('name') + ']:checked').val() : $(this).val(); 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.origVal', origVal);
@ -77,6 +77,14 @@
this.data('changetracker', true); 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. * Reset change state of all form fields and the form itself.
*/ */