Skip to content
This repository
Browse code

MINOR Added destroy() method to jQuery.changetracker plugin

  • Loading branch information...
commit 0b6d45356ebb9a55f07eb2834e0aab19227f4b2a 1 parent 6c1f799
Ingo Schommer authored June 13, 2012
12  admin/javascript/jquery-changetracker/lib/jquery.changetracker.js
@@ -67,8 +67,8 @@
67 67
 			
68 68
 			// setup original values
69 69
 			var fields = this.getFields();
70  
-			fields.filter(':radio,:checkbox').bind('click', onchange);
71  
-			fields.not(':radio,:checkbox').bind('change', onchange);
  70
+			fields.filter(':radio,:checkbox').bind('click.changetracker', onchange);
  71
+			fields.not(':radio,:checkbox').bind('change.changetracker', onchange);
72 72
 			fields.each(function() {
73 73
 				var origVal = $(this).is(':radio,:checkbox') ? self.find(':input[name=' + $(this).attr('name') + ']:checked').val() : $(this).val();
74 74
 				$(this).data('changetracker.origVal', origVal);
@@ -76,6 +76,14 @@
76 76
 
77 77
 			this.data('changetracker', true);
78 78
 		};
  79
+
  80
+		this.destroy = function() {
  81
+			this.getFields()
  82
+				.unbind('.changetracker')
  83
+				.removeClass(options.changedCssClass)
  84
+				.removeData('changetracker.origVal');
  85
+			this.removeData('changetracker');
  86
+		};
79 87
 			
80 88
 		/**
81 89
 		 * Reset change state of all form fields and the form itself.

0 notes on commit 0b6d453

Please sign in to comment.
Something went wrong with that request. Please try again.