[英]How can I define scripts in CakePHP?
Whenever I am trying to define 2 scripts this way: 每当我尝试以这种方式定义2个脚本时:
echo $this->Html->script(array('jquery', 'prototype'));
only prototype
is working. 只有
prototype
在工作。
When I do it this way: 当我这样做时:
echo $this->Html->script(array('prototype', 'jquery'));
only jquery
is working. 只有
jquery
的工作。
How do I fix it so both are working? 我该如何解决,以便两者都能正常工作?
That is because they both use the $
variable, and the second script overwrites the first. 这是因为它们都使用
$
变量,而第二个脚本将覆盖第一个脚本。
Try creating a script for the middle that only contains: 尝试为仅包含以下内容的中间件创建脚本:
$j = $.noConflict(); //sets `$j` as the jQuery variable
Then do: 然后做:
echo $this->Html->script(array('jquery', 'middleScript', 'prototype'));
在jQuery之后立即添加<script type="text/javascript">jQuery.noConflict();</script>
, 然后添加原型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.