test more generic js function

This commit is contained in:
Nathan Coad
2016-06-03 11:31:21 +10:00
parent fd084499b4
commit 59f30c70d7
2 changed files with 13 additions and 3 deletions

View File

@@ -358,6 +358,11 @@ function booking_manual_email_form($form, &$form_state, $input_option = "")
), ),
); );
$form['submit'] = array (
'#type' => 'submit',
'#value' => t('Send Email'),
);
$header = array( $header = array(
'booking_nid' => array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'), 'booking_nid' => array('data' => t('Id'), 'field' => 'nid', 'sort' => 'asc'),
'booking_name' => array('data' => t('Name'), 'field' => 'booking_lastname'), 'booking_name' => array('data' => t('Name'), 'field' => 'booking_lastname'),
@@ -503,7 +508,12 @@ function _booking_email_get_default_selection_callback($form, $form_state) {
'#type' => 'ajax', '#type' => 'ajax',
'#commands' => array( '#commands' => array(
ajax_command_replace("#booking_email_default_ids_wrapper", $output_html), ajax_command_replace("#booking_email_default_ids_wrapper", $output_html),
array('command' => 'bookingEmailIDs'), // This will call the command nameOfCommand we just created in the JS file. // This will call the command bookingEmailIDs in our custom JS file.
array('command' => 'bookingAjaxCheckboxes',
'formDataElement' => 'booking_email_default_ids'
'formName' => 'booking_manual_email_form',
'checkboxName' => 'table',
),
) )
); );
} }

View File

@@ -1,10 +1,10 @@
/** /**
* Special Effects AJAX framework command. * Special Effects AJAX framework command.
*/ */
Drupal.ajax.prototype.commands.bookingEmailIDs = function(ajax, response, status) { Drupal.ajax.prototype.commands.bookingAjaxCheckboxes = function(ajax, response, status) {
jQuery(function($) { jQuery(function($) {
var arr = $.parseJSON($('input#booking_email_default_ids').val()) var arr = $.parseJSON($('input#booking_email_default_ids').val())
$('#booking-manual-email-form').find(':checkbox[name^="table"]').each(function () { $('#booking-manual-email-form').find(':checkbox[name^="' . response.checkboxName .'"]').each(function () {
//.prop() doesn't exist in Drupal's old version of jQuery so use .attr() instead //.prop() doesn't exist in Drupal's old version of jQuery so use .attr() instead
$(this).attr("checked", ($.inArray($(this).val(), arr) != -1)); $(this).attr("checked", ($.inArray($(this).val(), arr) != -1));
}); });