0

I would like to make a system message appear using Javascript. I have used the following code so far to make the system message appear:

  var jmsgs = ['Deletion cancelled - no records deleted.'];
  Joomla.renderMessages({'alert': jmsgs });

This almost works as I want it. The message appears but the styling isn't working. This is how it is displaying.

Javascript system message

Normally when I use PHP to make the system messages appear they have CSS styling applied, eg using the following code:

$msg = 'Very helpful message';
JFactory::getApplication()->enqueueMessage($msg, 'message'); 

This is how it looks using PHP and how I want it to look using Javascript. PHP system message

Is there a way I can make Javascript display the system message so the styling is applied?

  • It looks like your template is overriding the styling for the enqueue messages. I would suggest looking at the HTML markup difference first – Lodder Jun 10 '15 at 13:11
  • Thanks @Lodder. I've had a look at the HTML and the javascript version is producing quite different markup so it explains the differences. But I have no idea what to do about it or how to get the javascript to product the same mark up as PHP... – Hannah Smith Jun 10 '15 at 16:27
  • Which template are you using? Could you provide a link to the template download page? – Lodder Jun 10 '15 at 17:25
  • I am using a custom template at the moment @Lodder but will have a go with protostar and see if I can figure it out. Thanks – Hannah Smith Jun 11 '15 at 9:08

Your Answer

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

Browse other questions tagged or ask your own question.