10

I would like to display a system message when I got back my ajax request.

The ajax request returns the right message. I can test it with an alert.

alert(result.message);
Joomla.renderMessages(result.message);

It will now show up the success or error message as a typical Joomla System Message. But the Joomla.renderMessages call, doesn't show any results. The system message won't appear on my site.

Is there anything wrong or do I have to do something more to get this to run?

2 Answers 2

6

All the things mentioned by @Bakual are correct but I notice that you are just passing the result.message to alert and given that [alert(message)][1] expects message to be a string or an object it can convert to a string this could be the problem.

If result.message is just a string, then you will need to wrap it in an appropriate container, something like this:

var jmsgs = [result.message];  // You can stack multiple messages of the same type
Joomla.renderMessages({'info': jmsgs });
1
  • that's the solution! Thx!
    – Perino
    Commented May 29, 2014 at 8:40
2

The JavaScript function depends on the presence of a container with the id system-message-container. Some templates don't have this container at all, or only if there is a message to show. So first check with Protostar and see if it works there

Also you need to make sure you actually loaded core.js with your extension. It isn't necessary loaded, especially not in frontend. Since Joomla 3.3 you can load it using JHtmlBehavior::core(), in earlier version you would use JHtmlBehavior::framework().

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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