From 12fc3de186c556c1f792bc1b00b56026921fa12f Mon Sep 17 00:00:00 2001 From: jordisan Date: Wed, 29 Apr 2015 09:48:50 +0200 Subject: [PATCH 1/2] Add 'checkDisabled' setting Add a setting to make it possible enable/disable disabled fields checking. Useful since 'propertychange' event is not supported by most browsers, so if you change the "disabled" attribute programmatically, the plugin doesn't work properly --- jquery.are-you-sure.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jquery.are-you-sure.js b/jquery.are-you-sure.js index 3c41e2f..a2db1b5 100644 --- a/jquery.are-you-sure.js +++ b/jquery.are-you-sure.js @@ -22,7 +22,8 @@ 'silent' : false, 'addRemoveFieldsMarksDirty' : false, 'fieldEvents' : 'change keyup propertychange input', - 'fieldSelector': ":input:not(input[type=submit]):not(input[type=button])" + 'fieldSelector': ":input:not(input[type=submit]):not(input[type=button])", + 'checkDisabled': true }, options); var getValue = function($field) { @@ -33,7 +34,7 @@ return null; } - if ($field.is(':disabled')) { + if (settings.checkDisabled && $field.is(':disabled')) { return 'ays-disabled'; } From 85df1cdad688cbf351b1a63b07be5444da89f717 Mon Sep 17 00:00:00 2001 From: jordisan Date: Wed, 29 Apr 2015 12:40:01 +0200 Subject: [PATCH 2/2] Add 'checkAttrName' setting Add a setting to make it possible enable/disable checking whether field has 'name' or not Useful if you are using AJAX, in which case you might have fields without "name" that you want to track --- jquery.are-you-sure.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jquery.are-you-sure.js b/jquery.are-you-sure.js index a2db1b5..65213e1 100644 --- a/jquery.are-you-sure.js +++ b/jquery.are-you-sure.js @@ -23,14 +23,15 @@ 'addRemoveFieldsMarksDirty' : false, 'fieldEvents' : 'change keyup propertychange input', 'fieldSelector': ":input:not(input[type=submit]):not(input[type=button])", - 'checkDisabled': true + 'checkDisabled': true, + 'checkAttrName': true }, options); var getValue = function($field) { if ($field.hasClass('ays-ignore') || $field.hasClass('aysIgnore') || $field.attr('data-ays-ignore') - || $field.attr('name') === undefined) { + || (settings.checkAttrName && $field.attr('name') === undefined)) { return null; }