2012-08-03 23 views
2
<default> 
    <reference name="head"> 
      <action method="addJs"><js>splurgyjs/jquery-1.7.2.min.js</js></action> 
    </reference> 
</default> 

這是在我的佈局文件夾hello.xml如何在管理員端使用jQuery而不使用其他所有模塊?

所以,問題是,我創建了一個新的導航標籤與使用jQuery的一個頁面,它完美的作品我的自定義模塊頁面上。但是,jQuery會在其他所有頁面上打破其他所有內容,如菜單停止工作,並且存在衝突。我如何才能在我的頁面上顯示佈局,或者如何在沒有衝突的情況下包含jQuery?

更新,我想湯姆的建議:

在config.xml中:

<layout> 
         <updates handle="index_settings"> 
         <embeds> 
                <file>justin.xml</file> 
           </embeds> 
        </updates> 
    </layout> 

在justin.xml:

<justin_index_settings> 
        
       <reference name="head"> 
           <action method="addItem"> 
      <type>js_css</type> 
      <name>justin/style.css</name> 
     </action> 
       </reference> 
   </justin_index_settings> 
+1

您是否在某處添加了'jQuery.noConflict()?如果沒有,請添加它。 Magento完全基於原型,它已經使用'$',因此與jQuery的'$'版本衝突。這可能是你的問題。 – 2012-08-03 22:02:05

+0

我只將它添加到我有我自己的jQuery的文件中 – Strawberry 2012-08-03 23:36:07

+0

對於'$'問題就足夠了。所以你可以把它拿出來。您可以將''移動到自定義的句柄中,並在'hello.xml'中的每個''中執行'。當你注意到將它放在''中時,它不會加載你的模塊中的所有頁面,而是通過系統中的所有頁面加載。 – 2012-08-04 08:09:27

回答

0

你的XML應該如下:

<my_own_custom_handle> 
    <reference name="head"> 
     <action method="addJs"><js>splurgyjs/jquery-1.7.2.min.js</js></action> 
    </reference> 
</my_own_custom_handle> 

然後從module_controller_action手柄。以Mage_Catalog模塊爲例,以<catalog_product_view>爲例。

<catalog_product_view> 
    <update handle="my_own_custom_handle" /> 
</catalog_product_view> 

這樣你的Javascript現在只裝了一個由catalog_product_view手柄產生的頁面,因此只產品detailpage而不是末頁等 你的情況,你只需要這個句柄調整到您的模塊句柄,可能是justin_index_settings

相關問題