From 56054b763aa8c9020267efe25ac616e4160f9723 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Fri, 3 Jun 2016 13:31:08 +1000 Subject: [PATCH] update js to add/remove selected class --- booking.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/booking.js b/booking.js index 24a9bb2..3c4e0a1 100644 --- a/booking.js +++ b/booking.js @@ -6,7 +6,13 @@ Drupal.ajax.prototype.commands.bookingAjaxCheckboxes = function(ajax, response, var arr = $.parseJSON($('input#' + response.formDataElement).val()) $('#' + response.formName).find(':checkbox[name^="' + response.checkboxName + '"]').each(function () { //.prop() doesn't exist in Drupal's old version of jQuery so use .attr() instead - $(this).attr("checked", ($.inArray($(this).val(), arr) != -1)); + if ($.inArray($(this).val(), arr) != -1) { + $(this).attr("checked", "true"); + $(this).addClass("selected"); + } else { + $(this).attr("checked", "false"); + $(this).removeClass("selected"); + } }); }); } \ No newline at end of file