mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
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
This commit is contained in:
parent
6514dc35d4
commit
54a7beb5e7
@ -34,13 +34,17 @@
|
||||
* @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'
|
||||
};
|
||||
@ -48,15 +52,11 @@
|
||||
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');
|
||||
@ -64,6 +64,9 @@
|
||||
$field.addClass(options.changedCssClass);
|
||||
self.addClass(options.changedCssClass);
|
||||
}
|
||||
})
|
||||
.each(function() {
|
||||
$(this).data('changetracker.origVal', $(this).val());
|
||||
});
|
||||
};
|
||||
|
||||
@ -71,9 +74,6 @@
|
||||
* 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');
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user