简体   繁体   English

jQuery滑块不适用于自己的jQuery变量

[英]Jquery slider doesn't work with own jQuery variable

I am creating a widget that will eventually sit on a clients site, and I need to create my own jQuery variable, so that the jquery versions don't conflict. 我正在创建一个最终将位于客户站点上的小部件,并且我需要创建自己的jQuery变量,以使jquery版本不会冲突。 Currently I have the following code: 目前,我有以下代码:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> // Clients own jquery.

<script type="text/javascript" src="sf_content/js/jquery-1.11.2.min.js"></script> // My jQuery.
<script type="text/javascript">
    var $sf_jquery = $.noConflict(true);
</script>

Everything else works just fine, but jQuery slider stopped working when I changed to my own jquery: 其他一切都正常,但是当我更改为自己的jquery时,jQuery滑块停止工作:

TypeError: $sf_jquery(...).slider is not a function TypeError:$ sf_jquery(...)。slider不是函数

Is the problem with the jQuery slider, or am I missing something else here? 是jQuery滑块出现问题,还是我在这里遗漏了其他东西?

Good plain javascript slider -tips are welcome as well! 好的普通javascript滑块-也欢迎使用提示!

Edit : Everything the widget needs, is inside function call like this: 编辑 :窗口小部件需要的所有内容都在函数调用中,如下所示:

$sf_jquery(function(){ // all of the code here });

Edit : The jQuery Ui is imported aswell. 编辑 :jQuery Ui也被导入。 Just forgot to add it here. 只是忘了在这里添加。 The importing looks like this: 导入看起来像这样:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> // Clients own jquery.

<script type="text/javascript" src="sf_content/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
    var $sf_jquery = $.noConflict(true);
</script>
<script type="text/javascript" src="sf_content/js/jquery-ui.min.js"></script>

Edit, Solution! 编辑,解决方案! Dummy me didn't think that the slider isn't part of the native jQuery. 愚蠢的我不认为滑块不是本机jQuery的一部分。 The noConflict must be after the jQueryUI, like this: noConflict必须在jQueryUI之后,如下所示:

<script type="text/javascript" src="sf_content/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="sf_content/js/jquery-ui.min.js"></script>
<script type="text/javascript">
    var $sf_jquery = $.noConflict(true);
</script>

You aren't including jQueryUI code (at least in your example). 您没有包括jQueryUI代码(至少在您的示例中)。

Slider is part of jQueryUI and is not native to jQuery alone. Slider是jQueryUI的一部分,并不是jQuery本身所固有的。 ( https://jqueryui.com/slider/ ) https://jqueryui.com/slider/

您的“ noconflict”函数必须在第二个jQuery调用之前被调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM