dongmei8209 2012-09-12 20:04
浏览 23

在TOP的顶部添加一个带有块的jQuery

I have an extension in magento which adds a block in the header for loading jQuery:

<reference name="head">            
     <block type="page/html" 
            template="csdev/embedjquery/embed_jquery.phtml" 
            output="toHtml" 
            name="csdev_embedjquery" />
</reference>

The content of the block is the following:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js" />

<script type="text/javascript">    
    $.noConflict();
    alert(jQuery);
</script>

The problem is that jQuery will be added too late, after prototype. It needs to added before prototype, so i can execute the noConflict() function.

Also, since I don't want to overwrite the magento head-template or the magento head-block, I added the following:

output="toHtml"

but that's too late :(...

Is there a solution such as "add this block on top of the reference (head) with output='toHtml'"?

I tried:

before="-"

but it doesn't seem to work, because I wrote:

output="toHtml"

My Magento Version is 1.7.

  • 写回答

2条回答 默认 最新

  • douzai2562 2012-09-12 20:12
    关注

    Your problem is that you are adding it as a phtml file, instead of a JS file. Try adding this instead into page.xml, within default -> root -> head (around lines 37 to 61):

    <action method="addJs"><script>jquery/jquery.js</script></action>
    

    Then create a folder within /js called jquery, and upload jquery.js into that file. At the end of the jquery.js file, append the noConflict method call. That should fix your problem.

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算