I've got javascript that notifies the user of actions and errors, and I'd like to use the existing Drupal messaging. Is this built in to Drupal?

Alternatively, (I'm fairly new to Drupal and am not very familiar with the modules available) if this is available as a module, I haven't been able to find it. Does anyone know of a module?

UPDATE: To clarify, I'm trying to set a Drupal message from the client-side (JavaScript), on a page that has already rendered. This is a very AJAXy page with tonnes of functionality that sometimes requires messages be shown to the user.

Is there is a provision in the Drupal client-side API for setting messages?

  • 1
    hello. I do not know if others, but to me your question is not all clear (sorry). do you want show messages from a module of Drupal using javascript? – cigotete Aug 19 '11 at 14:35
  • Can you post some of your javascript code? – Martin Schlagnitweit Aug 19 '11 at 17:03
  • @Martin Schlagnitweit This is legacy js that I'm porting into Drupal... the legacy code is kind of irrelevant -- it just manually created it's own message in the old system. – Jay Querido Aug 19 '11 at 17:38
  • If there is nothing in the client-side API for this, I guess this is a good candidate for a new module?! – Jay Querido Aug 19 '11 at 17:39
  • @moon.watcher I want to show messages from JavaScript. Incidentally, this js is part of a module, but I don't think that's relevant in this case. – Jay Querido Aug 19 '11 at 17:41

I don't see JS API for dispaying messages even in D7. Maybe because all you need is DIV with classes like messages,status warning or error. You can see how drupal works with it in file /misc/tabledrag.js.
When you drag rows in tables drupal shows you a warning message with this code:

  • Okay, that's it then... I smell a new module coming on to reduce duplicate code... Thanks @kalabro – Jay Querido Aug 19 '11 at 20:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.