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?

5

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 });
  • that's the solution! Thx! – Perino May 29 '14 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().

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.