简体   繁体   English

如何使用细丝的daterangepicker与新的jQuery?

[英]how to use filament's daterangepicker with new jquery?

I downloaded the daterangepicker available here : filament group 我从此处下载了daterangepicker: 细丝组

I am using jQuery 1.4.x version in my page, and all other plugins I am using are supported only on latest version of jQuery. 我在页面中使用的是jQuery 1.4.x版本,而我使用的所有其他插件仅在最新版本的jQuery上受支持。 The daterangepicker tool fails because it is using date.js (which uses a very old jQuery). daterangepicker工具失败,因为它使用的是date.js(它使用的是非常老的jQuery)。

If I use datepicker, all other plugins and functionality of rest of the plugins I am using are lost. 如果我使用datepicker,则所有其他插件以及我正在使用的其余插件的功能都会丢失。

I went through filament group's comments and found this : 我通过细丝小组的评论,发现了这一点:

@ Mckensy: We made sure to use “jQuery” instead of $ to prevent such collisions but it appears the date.js library uses $, which is probably causing your conflict. // @ Mckensy:我们确保使用“ jQuery”而不是$来防止此类冲突,但是date.js库似乎使用了$,这很可能导致您的冲突。 Maybe you could try replacing their $ variables with something else. 也许您可以尝试将它们的$变量替换为其他变量。

he means that noConflict mode doesn't work and only way is to change date.js. 他的意思是noConflict模式不起作用,唯一的办法是更改date.js。

Now can someone please tell me how to do what he says ?? 现在有人可以告诉我怎么做他说的吗?

It's been worked on some at: https://github.com/filamentgroup/jQuery-UI-Date-Range-Picker 它已经在以下网站上进行过处理: https : //github.com/filamentgroup/jQuery-UI-Date-Range-Picker

Deploying this worked for me on jqueryUI 1.8.9. 在jqueryUI 1.8.9上部署它对我来说很有效。

Try wrapping your date.js code in a (function(){})() and inside this function at the end all the date.js code, assign a global variable so you can reference the local data.js $ variable. 尝试将您的date.js代码包装在(function(){})()并将所有date.js代码最后放在此函数内部,分配一个全局变量,以便您可以引用本地data.js $变量。

(function() {

// date.js code
var $ = someDataJsStuff();

// .. more code ..

// make a global var to reference this date.js stuff (not $ of course)
dateJsVariable = $;

})();

This will avoid any namespace cluttering. 这将避免任何名称空间混乱。 Only that final global variable will clutter so that you can use the library :) 只有最后的全局变量会混乱,以便您可以使用库:)

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

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