0

The SweetAlert modal is not displaying the content as passed in the option array when returning a response from the controller. Please see the code config below:

//$options                      = array();
    $options                        = SweetAlertCommand::defaultOptions();
    $options['title']   = 'Appointment Details';
    $options['html']        = TRUE;
    $options['content'] = '<div class="row">'.
                                                  '<div class="modal-item col-sm-3">'.
                                                    '<p class="txt">Last Name</p>'.
                                                    '<p class="item-details">'.$results['last_name'].'</p>'.
                                                  '</div>'.
                                                  '<div class="modal-item col-sm-3">'.
                                                    '<p class="txt">First Name</p>'.
                                                    '<p class="item-details">'.$results['first_name'].'</p>'.
                                                  '</div>'.
                                                  '<div class="modal-item col-sm-3">'.
                                                    '<p class="txt">Email ID</p>'.
                                                    '<p class="item-details">'.$results['email'].'</p>'.
                                                  '</div>'.
                                                  '<div class="modal-item col-sm-3">'.
                                                '</div>';

    $response                   = new AjaxResponse();
    $response->addCommand(new SweetAlertCommand($options));
    return $response;

When the alert is triggered the alert comes as blank. Any leads? I am using the sweetalert module https://www.drupal.org/project/sweetalert

  • I dont know of an option called 'content'. The module was written against version 1 of Sweet Alert. sweetalert.js.org . But looking here, it looks like content was not meant in that way? sweetalert.js.org/docs – Kevin Nov 1 at 20:24
  • @Kevin Correct. As per version 1 we have "text" instead of "content" however that is also not working. The alert comes as blank. The html string in "text" is not being rendered. – Prerit Mohan Nov 4 at 16:31
  • Not sure what to say, unless there is a browser console error or application error logged somewhere. It works/worked for me. – Kevin Nov 4 at 17:09
  • I dont see any errors in console. Can you share your php code definition for this sweetalert? @Kevin – Prerit Mohan Nov 4 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.