插件未加载 [英] Plug in does not load
本文介绍了插件未加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我的插件无法加载?引用了jquery和插件链接.该插件称为.. ..请帮助我找到代码中所缺少的内容.
Why does not my plug in load? The jquery and plug in links are referenced. The plug in is called .. .. Please help me find what I am missing in the code.
<script src="~/Scripts/jquery-1.7.1.js"></script>
<script src="~/Scripts/chosen.jquery.js"></script>
<select class="chzn-select" tabindex="1" style="width:350px;" data-
placeholder="Choose a Country">
<option value=""></option>
<option value="United States">United States</option>
<option value="United Kingdom">United Kingdom</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
</select>
<script>
$(document).ready(function(){
$(".chzn-select").chosen();
});
</script>
我收到萤火虫错误:
TypeError:$(...).chosen不是函数
TypeError: $(...).chosen is not a function
推荐答案
阅读注释并搜索相关问题,我发现原因是因为jQuery被两次包含.查看此.
Reading the comments and searching for the related issue I found out that the reason is that because the jQuery was being included twice. Look at this.
我创建了这个小提琴,其中包括我从
I created this fiddle where I am including chosen from this cdn service.
如果jquery只被包含一次
If jquery is included only once than
$(".chzn-select").chosen();
应该工作正常.
代替使用
$(document).ready(function(){
$(".chzn-select").chosen();
});
尝试
$(document).bind("pageinit", function() {
$(".chzn-select").chosen();
});
这篇关于插件未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文