2012-08-03 47 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

相关问题