diff --git a/js/dependent.js b/js/dependent.js index cca3622..b8e5fba 100644 --- a/js/dependent.js +++ b/js/dependent.js @@ -99,8 +99,14 @@ else { switch ($(trigger).attr('type')) { case 'checkbox': - var val = $(trigger).attr('checked') || 0; - + // **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute + if ($().prop){ + var val = $(trigger).prop('checked') || 0; + } + else { + var val = $(trigger).attr('checked') || 0; + } + if (val) { $(trigger).siblings('label').removeClass('hidden-options').addClass('expanded-options'); } @@ -168,16 +174,31 @@ if (Drupal.settings.CTools.dependent[id].type == 'disable') { if (Drupal.settings.CTools.dependent[id].num <= len) { // Show if the element if criteria is matched - object.attr('disabled', false); - object.addClass('dependent-options'); - object.children().attr('disabled', false); + // **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute + if(typeof $().prop == 'function') { + object.prop('disabled', false); + object.addClass('dependent-options'); + object.children().prop('disabled', false); + } + else { + object.attr('disabled', false); + object.addClass('dependent-options'); + object.children().attr('disabled', false); + } } else { // Otherwise hide. Use css rather than hide() because hide() // does not work if the item is already hidden, for example, // in a collapsed fieldset. - object.attr('disabled', true); - object.children().attr('disabled', true); + // **This check determines if using a jQuery version 1.7 or newer which requires the use of the prop function instead of the attr function when not called on an attribute + if(typeof $().prop == 'function') { + object.prop('disabled', true); + object.children().prop('disabled', true); + } + else { + object.attr('disabled', true); + object.children().attr('disabled', true); + } } } else {