2010-11-18 115 views
0

我在視圖頁面使用「視覺效果」,但它不工作可以任何身體幫助我。在軌道上紅寶石不工作的視覺效果

下面的代碼去

<%= 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> 
+1

什麼版本的軌道您使用的是? – 2010-11-18 09:33:44

+0

不工作是什麼意思?你有一些錯誤報告?在螢火蟲 – shingara 2010-11-18 09:54:01

回答

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> 
+0

我得到像未捕獲的異常[對象,對象] – 2010-11-18 11:02:27

0

你應該把它放在一個文件(DOM)準備塊,或者JS之前移動#important頁。就目前而言,js在知道#important p之前運行,所以沒有任何反應。如果它處於文檔就緒塊中,那麼順序並不重要,因爲整個頁面將在js運行之前加載。另外,:淡入淡出似乎沒有做任何事情。嘗試:突出顯示。

在原型你做這樣一個DOM準備塊:

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