<default>
<reference name="head">
<action method="addJs"><js>splurgyjs/jquery-1.7.2.min.js</js></action>
</reference>
</default>它在我的布局文件夹hello.xml中
所以问题是,我创建了一个新的导航选项卡,其中包含一个使用jQuery的页面,它在我的自定义模块页面上工作得很好。然而,jQuery破坏了其他页面上的所有东西,比如菜单停止工作,这是冲突的。如何才能仅在页面上显示布局,或者如何才能在没有冲突的情况下包含jQuery?
更新,我尝试了Tom的建议:
在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>发布于 2012-08-07 03:56:31
您的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句柄生成的页面加载,因此只有一个产品详细信息页面,而不是列表页等。在您的示例中,您只需要将此句柄调整为您的模块句柄,可能是justin_index_settings。
https://stackoverflow.com/questions/11802780
复制相似问题