AnswerBun.com

Is there a reliable way to show Drupal messages from JavaScript?

Drupal Answers Asked by infojunkie on November 8, 2021

I need to show status messages (the kind typically shown by drupal_set_message()) in my module’s JavaScript code. How can I do this reliably, such that the theme and placement of the messages remains consistent with the way drupal_set_message() does it?

I’m looking for a solution that accounts for the presence or absence of prior messages on the page, and that works for any theme.

Pointing to existing modules that perform this would be great!

One Answer

I'm using Nice messages module to replace every message with a popup in the corner of the screen.

https://drupal.org/project/nicemessages

It lets you choose if you want the messages of a status to stay visible until closed, or auto close after x seconds. And add a handy "close all" if there are more than one.

If anything, check out how it works. It's a good starting point i guess.

Answered by Astrayus on November 8, 2021

Add your own answers!

Related Questions

How can I rebuild an image field with values in an Ajax callback?

1  Asked on December 17, 2020 by wassim-akermi

     

Breadcrumb/block settings

3  Asked on December 17, 2020 by zach

       

Change can I programmatically change the format of a view?

2  Asked on December 16, 2020 by user78498

   

How do I create a conditional form field?

2  Asked on December 15, 2020 by sean

 

I need to reference a custom field I created in User Profile

1  Asked on December 15, 2020 by user17021

     

How to use the uc_csv module for getting reports

1  Asked on December 15, 2020 by sathish

     

CKEditor displays entire site page when rich text is switched on

1  Asked on December 13, 2020 by amit-sedai

 

How do I get the video media path in a theme?

1  Asked on December 12, 2020 by mrfox

 

drush cannot update commerce kickstart

1  Asked on December 9, 2020 by ckosloff

   

How to add a javascript function after uploading file

2  Asked on December 9, 2020 by ahmed

   

Creating date field with only month and year

2  Asked on December 8, 2020 by blaine-lang

   

submitForm() isn’t called

1  Asked on December 7, 2020 by dylhof

     

Get the uri/path value of an image in the field template

2  Asked on December 7, 2020 by flamesquirrel

       

User registration silently fails – how to debug?

1  Asked on December 5, 2020 by druvision

     

How can I automatically flag new comments?

1  Asked on December 5, 2020 by sdfff

       

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP