I just implemented a multi-language mod onto my website.
Problem is that there seems to be a conflict between the javascript files from the language mod and the javascript files that already were on the page.
<!-- language files here -->
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/translationEngine.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/jquery.translate-1.3.9.min.js"></script>
<script>var browserlang = 'en';</script>
<!-- Javascript -->
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.pngFix.pack.js"></script>
<script type="text/javascript" src="js/jquery.flow.1.2.min.js"></script>
<script type="text/javascript" src="js/jquery.prettyPhoto.js"></script>
<script type="text/javascript" src="js/concept.js"></script>
js/jquery-1.3.2.min.js is what makes the 3 image slider on the homepage work, but... it seems to also be interfering with the functions of the translator.
If u remove js/jquery-1.3.2.min.js from the page, the translator works fine, but the slider no longer works.
removing js/jquery-1.4.2.min.js from the page doesnt make the translator work either, in fact it seems to cause more errors in the back.
Can someone guide me in the right direction that would allow me to make the language translator and image slider both work?
http://filefx.com
Thanks :)
The short version is to remove this:
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
And update your plugins, there are likely 1.4.x versions out there for each of them. By including jQuery a second time, like you are currently, it'll wipe out plugins and cause all sorts of issues...the first step is removing the second (hopefully the older) instance.
Edit: Here's an updated version of jFlow called jFlow plus that works with 1.4.2.
Check out the jQuery noConflict function. This function tells jQuery to relinquish it's control over the $ variable. This way, other libraries can use it.
The online docs give a pretty good guide as to how to use this function. It saved me a few times.
Example from the online docs:
<script type="text/javascript" src="other_lib.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ can follow here.
});
// Code that uses other library's $ can follow here.
</script>
Basically, once you call noConflict, you can still use jQuery, just use it using the jQuery variable name instead of $.
Hope this helps!
I have alway solved conflicts between two versions of jquery e.g. jQuery 1.3.2 and jQuery 1.4.2 on the same page using iframes but i recently found out that you can use version jquery-1.5.1.js alone and everything works fine.
I change all the .js file on the page used from below code:
<script>
var K = jQuery.noConflict();
alert(K);
jQuery(document).ready(function () {
alert("Bye");
});
</script>
It works fine now.
I ended up just changing the order in which the libraries loaded.
I let all the jquery libraries load first, from newest to oldest. Then i called for the javascript files that rely on jquery.
It works fine now.
Related
My website uses jquery version 1.11.o and I would like to use ResponsiveSlides.js from GitHub to show a slideshow on my home page but ResponsiveSlides.js uses jquery version 1.8.3 and it conflicts with v1.11.0 so my site breaks.
I have tried the solution below that I found in another question so that I can use both jquery version but it didn't work. How can I accomplish this and use both jquery versions without conflict?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<script>var $j = jQuery.noConflict(true);</script>
<script>
$(document).ready(function(){
console.log($().jquery); // This prints v1.11.0
console.log($j().jquery); // This prints v1.8.3
});
Using 2 versions of jQuery is not recommended and will cause a load of problems. You should use the jQuery migrate plugin. The plugin restores deprecated features and behaviors so that older code will still run properly on jQuery 1.9 and later. The latest versions would be used like this:
<script src="jquery-1.12.3.min.js" type="text/javascript"></script>
<script src="jquery-migrate-1.3.0.min.js" type="text/javascript"></script>
I'm a newbie to web dev, so please stick with me. I know this question has come up a lot (or a similar deviation), but after a couple of hours of searching I have not found an answer that works for me.
I've made sure the JQuery file is loaded first, and tried multiple versions to no avail. Whenever I try to load the Magnific Popup script, I get (TypeError: $ is not a function) on line 50. I've had a look and tried to change $ to JQuery to no avail, so it's back to normal now.
Here's the Magnific Popup code block:
var mfp,
MagnificPopup = function(){},
_isJQ = !!(window.jQuery),
_prevStatus,
_window = $(window), <<<<<< ERROR HERE
_document,
_prevContentType,
_wrapClasses,
_currPopupType;
And the relevant html:
<head>
<link rel="stylesheet" href="css/magnific-popup.css">
</head>
<body>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.magnific-popup.js"></script>
</body>
looks like its not picking your jquery library from CDN..
make sure that you have the network in your system or have access to jquery CDN url
if all above is fine then you try with http in CDN url like below. this is working for me
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Try to load your jquery file from your own (local) machine. Hopefully, this will work well.
Also, it would be helpful for me if you please let me know that you are not getting 404 for the JQuery file from the CDN.
I have a website using twitter bootstrap. When developing sometimes the internet is not working so jquery won't be loaded and my site will not work. This is why I have a local copy of jquery in my js folder. I edited bootstrap files so if jquery is not detected the browser will change the location of jquery from cdn to my local file. I tried to do that but it is not working:Here is my code:
if (!window.jQuery) {
document.getElementById('jq').src='../../js/jquery.js';
console.log("You are using a backup file of jquery provided by our website");
}
else{
console.log("jQuery has been succesfully loaded by kounelios13");
}
html:
<script src="http://code.jquery.com/jquery-1.11.0.min.js" id="jq"></script>
<script src="../../js/bootstrap.js" type="text/javascript"></script>
<script src="../../js/prefixfree.js" type="text/javascript"></script>
<script src="../../js/apps/rgba.js" type="text/javascript"></script>
This is placed inside bootstrap's js file.
Any ideas???
Imaging that CDN file is not available. Then browser starts loading next script file (bootstrap.js), parser enters bootstrap.js, where you placed your check for jQuery. Your code detects that jQuery is not loaded and the script then changes src of the jq tag. It works fine and jQuery starts loading, however browser doesn't wait until jQuery is downloaded and carry on to the Bootstrap stuff, which fails immediately, because it requires jQuery. Hence the error.
You can try this version for backup jQuery library instead which should be reliable:
<script src="http://code.jquery.com/jquery-1.11.0.min.js" id="jq"></script>
<script>
if (!window.jQuery) {
document.write("<script src='../../js/jquery.js'>\x3C/script>");
}
</script>
<script src="../../js/bootstrap.js" type="text/javascript"></script>
<script src="../../js/prefixfree.js" type="text/javascript"></script>
<script src="../../js/apps/rgba.js" type="text/javascript"></script>
With jquery I don't thinks bootstrap script work so you need that.
If you have internet problem then you can copy jquery link and make file of that and attached.
ID must unique for the Document, you have another Element that uses the id jq or none.
I have a project built on top of Zurb Foundation, now I need to use some FuelUX components such as "wizard" and "tree". For that I include Twitter Bootstrap library (2.3.2 version downloaded from Bootstrap site) and also include "all.min.js" from FuelUX, when I use the same HTML markup as come in index.html but for some reason it doesn't work. So I tried to fire the plugin using $("#MyWizard").wizard() and get this error:
TypeError: $(...).wizard is not a function
$("MyWizard").wizard();
Any ideas in how to get this work?
How I include scripts
This is the order in which I include scripts:
<script type="text/javascript" src="/bundles/product/js/bootstrap/bootstrap.min.js?0.1"></script>
<script type="text/javascript" src="/bundles/product/js/fuelux/all.min.js?0.1"></script>
<script type="text/javascript" src="/bundles/stock/js/jquery-impromptu.js?0.1"></script>
<script type="text/javascript" src="/bundles/product/js/product.js?0.1"></script>
<script>
$("MyWizard").wizard();
</script>
This was also posted to https://github.com/ExactTarget/fuelux/issues/259 and from what I'm seeing, being careful to follow the instructions at https://github.com/ExactTarget/fuelux/wiki/Using-Fuel-UX#simple-integration-into-a-page should straighten things out. Hope this helps!
I'm currently running a couple different jQuery libraries on my website, here
The rotating banner is from http://codecanyon.net/item/li-jquery-sliderimage-rotator/full_screen_preview/153638
Which has me include these files
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/li-slider-animations-1.1.min.js"></script>
<script type="text/javascript" src="js/li-slider-1.1.min.js"></script>
I also am using fancybox (http://fancybox.net/howto) and include the necessary javascript files.
I got everything working fine until I tried to use this plugin, (http://plugins.jquery.com/project/tipsy)
I could not get that tipsy plugin to work without removing these javascript files from my header
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
I realize I'm probably doing something wrong by including all of these different jquery libraries, but how can I go about having everything work at the same time even though they appear to be using different files.
I included my site URL so you can check the source file to see if there is something I should fix and what I should do so I can add the correct tipsy files.
Thanks
You cannot use multiple versions of the jQuery library on the same page.
How would a script know what library to use?
Only include 1 jQuery script and find updated / other jQuery plugins if they are incompatible.
Or write the needed functionality yourself.