0

I am using "visual effects" in the view page but its not working can any body help me.

Here the code goes

<%= javascript_include_tag "prototype", "effects" %>
<script type="text/javascript">
    <%= visual_effect(:fade, "important", :duration => 1.5) %>
</script>

<p id="important">Here is some important text, it will be highlighted when the page loads.</p> 
2
  • 1
    What version of rails are you using ? Nov 18, 2010 at 9:33
  • What do you mean by not working ? Have you some error report ?
    – shingara
    Nov 18, 2010 at 9:54

2 Answers 2

1
<%= javascript_include_tag "prototype", "effects" %>
<p id="important">Here is some important text, it will be highlighted when the page loads.</p> 
<script type="text/javascript">
     <%= visual_effect(:fade, "important", :duration => 1.5) %>
</script>
1
  • in firebug I am getting the error like uncaught exception [object,object] Nov 18, 2010 at 11:02
0

You should put it in a document (dom) ready block, or move the #important p before the js. As it stands the js is run before it knows about the #important p so nothing happens. If it's in a document ready block then order isn't important as the whole page will be loaded before the js is run. Also, :fade doesn't seem to do anything. Try :highlight instead.

In prototype you do a dom ready block like this:

<script type="text/javascript">
  document.observe('dom:loaded', function() {
    <%= visual_effect(:fade, "important", :duration => 1.5) %>
  });
</script>

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.