lightbox2与脚本冲突
lightbox2 is conflicting with scripts
我将LightBox2用于一个简单的图像库。我设法使它工作,但现在它与我在页面中引用的另一个javascript脚本文件冲突。
我的脚本正在使用$(document).ready(function () {
我不确定它是否相关,但我知道浏览器的调试器曾经抱怨过它
对此有什么见解吗?
============================================================我包含了生成错误的部分代码。尽管这一切都很顺利。
var currs={};
jQuery.noConflict();
jQuery(document).ready(function () {
var marketTypeSel = document.getElementById("selMarketType");
var propertyTypeSel = document.getElementById("selPropertyType");
var propertyStatusSel = document.getElementById("selPropertyStatus");
var zoneSel = document.getElementById("selZone");
var locSel = document.getElementById("selLocalities");
var currSel = document.getElementById("selCurrency");
var priceFromSel = document.getElementById("selPriceFrom");
var priceToSel = document.getElementById("selPriceTo");
//var data = {};
marketTypeSel.length = 0;
propertyTypeSel.length = 0;
propertyStatusSel.length = 0;
zoneSel.length = 0;
locSel.length = 0;
currSel.length = 0;
jQuery.ajax({
type: "POST",
url: "/Search/LoadInitSearchParameters",
//data: data,
dataType: "json",
success: function (result) {
您可以在下面使用没有冲突的jquery
var Jk = jQuery.noConflict();
Jk(document).ready(function (){
});
您可以使用
jQuery.noConflict();
var Jq = jQuery.noConflict();
Jq(document).ready(function (){
});
或
JQuery(document).ready(function (){
});
使用jquery 时,只需使用jQuery
而不是$
如果仍然不起作用,请在关闭body标记之前添加所有脚本引用,即代替head标记。我面临着同样的问题,这个技巧对我来说很有效
像低于
<body>
<div>Dummy Data</div>
<div>Dummy Data</div>
<script src="/App_Themes/lib/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="/App_Themes/lib/jquery.jcarousel.js" type="text/javascript"></script>
<script src="/App_Themes/lib/jquery.easing.1.2.js" type="text/javascript"></script>
//Also lightbox ref
</body>
这适用于Lightbox2 2.8.1。
当您使用jQuery(document).ready(function () {});
时,这将阻止灯箱初始化。
我发现我必须添加lightbox.init()
,因为我的代码正在阻止lightbox2的加载。
$(function() {
lightbox.init();
// other code
}
相关文章:
- 为什么'滚动到顶部'脚本导致类型错误?jQuery冲突
- jQuery插件冲突和脚本声明顺序
- 同一页面上的多个Jquery脚本冲突
- jQuery与核心Joomla脚本冲突
- "$"未定义;jquery在<头部>;没有冲突的脚本或库
- 意外的脚本/css冲突,如何解决
- 冲突的脚本#选择器标记
- 脚本代码冲突
- PHP密码脚本和JavaScript刷新冲突,发出我想消除的表单重新提交消息
- 冲突的jQuery脚本(NoConflict修复了一个,但破坏了另一个)
- jquery与JS脚本冲突
- 为什么这 3 个 greasemonkey (javascript) 脚本相互冲突
- j查询冲突问题 - 停止运行脚本
- Google AMP 脚本与 jquery window.scroll 冲突
- Javascript 冲突 ajax 邮件和脚本
- RequireJS :处理与填充程序和非AMD加载脚本的jQuery冲突
- 冲突的脚本不起作用
- HTaccess与Ajax脚本冲突
- 冲突的 jQuery 对话框脚本
- 脚本冲突Mootools验证与jQuery幻灯片