visual effects not working in ruby on rails
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>
<%= 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>
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>
精彩评论