Search code examples
jqueryruby-on-railscdatagrowl

Displaying CDATA in a rails app


I'm using the gritter_notices gem to replace flash alerts with a growl-type notification. I've got as far as this code appearing in the rendered HTML:

  <script type="text/javascript">
  //<![CDATA[
  jQuery.gritter.add({image:'/assets/success.png',title:'Success',text:'Record was successfully saved.'});
  //]]>
  </script>

And this in application.html.haml

  = gflash
  = gritter_flash_messages
  = yield
= javascript_include_tag "application"
= include_gritter

But nothing's showing up. Help?!


Solution

  • I do not know gritter, but I suspect your shown code is run before gritter is loaded. Hook it to something like document.loaded event so it executes when the full page is loaded.

    You can catch this by using your browsers debugging tools.