Noty will only display a noty when drupal_set_message is used server side during the initial page load.

Noty will not display a noty when drupal_set_message is used in an ajax call.

It would be great if noty also appeared during an ajax call.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jamesdixon created an issue. See original summary.

jamesdixon’s picture

Component: Documentation » Code
jamesdixon’s picture

Assigned: jamesdixon » Unassigned
Status: Active » Needs review
FileSize
7.79 KB

I created a patch which adds ajax support to this module. It required several changes to the module as the module was only designed to work on page load.

Server side, when theming the messages, the updated code is checking if an ajax request was made. If an ajax request was made, then it won't bother with the drupal_add_js method to update the Drupal.settings variables with the new Noties, as that doesn't work.

Instead when all ajax requests have completed during the jQuery.stopAjax() event, an ajax call is made to the noty_messages module asking if drupal_set_messages was called, and if we need to update Drupal.settings with any more noties. In the ajax success method, if noties were found, then they are rendered.

This may not be the best method to do this, but it appears to work for my purposes.

This also includes the patch which removes duplicate noty messages:

https://www.drupal.org/node/2028591
https://www.drupal.org/node/1862940

This patch should solve this related issue:
https://www.drupal.org/node/2254369

jamesdixon’s picture

The previous patch caused an issue with tokens because there was a define statement at the top of the module file defined like this:

define('NOTY_MESSAGES_AJAX_URL', url('noty_messages/ajax'));

I've refactored the patch to fix this issue.

Here's the issue we were experiencing:

https://www.drupal.org/node/1265848#comment-11424803

d70rr3s’s picture

Status: Needs review » Closed (outdated)