Permalink
Browse files

BUGFIX Fixed fieldSelector logic in jquery.changetracker

MINOR Fixed removeData() invocation in jquery.changetracker
MINOR Removed debug code in jquery.changetracker

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92683 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 6514dc3 commit 54a7beb5e73046150e32e12436a2f25f78b4efcf @chillu chillu committed Nov 21, 2009
Showing with 13 additions and 13 deletions.
  1. +13 −13 javascript/jquery-changetracker/lib/jquery.changetracker.js
@@ -34,46 +34,46 @@
* @license BSD License
*/
$.fn.changetracker = function(_options) {
- if (this.length > 1){
- this.each(function() { $(this).changetracker(_options); });
+ var self = this;
+
+ if(this.length > 1){
+ this.each(function(i, item) {
+ this.changetracker(_options);
+ });
return this;
}
-
+
this.defaults = {
- fieldSelector: ':input:not(:submit),:select:not(:submit)',
+ fieldSelector: ':input:not(:submit)',
ignoreFieldSelector: "",
changedCssClass: 'changed'
};
var options = $.extend({}, this.defaults, _options);
this.initialize = function() {
- var self = this;
-
// optional metadata plugin support
if ($.meta) options = $.extend({}, options, this.data());
// setup original values
- this.getFields().each(function() {
- $(this).data('changetracker.origVal', $(this).val());
- })
+ this.getFields()
.bind('change', function(e) {
var $field = $(e.target);
var origVal = $field.data('changetracker.origVal');
if(origVal === null || $field.val() != origVal) {
$field.addClass(options.changedCssClass);
self.addClass(options.changedCssClass);
}
+ })
+ .each(function() {
+ $(this).data('changetracker.origVal', $(this).val());
});
};
/**
* Reset change state of all form fields and the form itself.
*/
this.reset = function() {
- console.debug('reset called');
- var self = this;
-
this.getFields().each(function() {
self.resetField(this);
});
@@ -88,7 +88,7 @@
* @param DOMElement field
*/
this.resetField = function(field) {
- return $(field).data('changetracker', null);
+ return $(field).removeData('changetracker.origVal');
};
/**

0 comments on commit 54a7beb

Please sign in to comment.