Logged Out
Create an Account
Login:
Password:

Forgot your password?
jQuery library order conflict

jQuery library order conflict
[Back to Index]  [Bottom of Thread]
Thread Tags
Primary: [Advanced Layout]
Secondary: [Support]
I notice that my site is loading jQuery 1.3.2 library after my layout.html ends, which I believe will overwrite any jQuery plugin I add myself.

I've been trying to use carhartl's jQuery cookie plugin. Not knowing 1.3.2 was being loaded at all, my page was doing this:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script> <!--Load 1.9.1 library-->
<script type="text/javascript" src="http://dkpfiles.com/excineribus/files/jquery.cookie.js"></script> <!--define $.cookie functions-->
<script type="text/javascript" src="settings/dkp-extras/jq/jquery-1.3.2.min.js"></script> <!--Load 1.3.2 library, overwrite previous $ definitions-->


It is my understanding that the jQuery library must be defined before any plugins, or those plugins will not work. Help?

--
Ieyasu - Organizer, Ex Cineribus
Hey Nitesbane,

Let me tinker with things, and see if I can't simplify this for you.

The simple solution may be to just upgrade jquery, and see if any of the jquery deprecations break anything.

--
It's all in the reflexes.
You'd probably know better than me, but the limited sources I have access to indicate it's just the order in which they're being loaded...?

I'm told that I should, theoretically, be able to use 1.3.2 without issue if it loaded as the first element of the page so that I could place my plugin after.

Does this make any sense? I've seen it mentioned a few times in online discussion, but to call me an amateur or beginner programmer would be exceedingly generous. I feel like I'm walking down a dark hallway bumping into things until I find the end.



--
Ieyasu - Organizer, Ex Cineribus
If jquery.cookie.js will work on jquery 1.3, then you could try adding the following, which uses a helper function (jq_preload) for the purposes of doing things after jquery loads.

<script language=javascript>
jq_preload(function(){
      jQuery.getScript("http://dkpfiles.com/excineribus/files/jquery.cookie.js");
});
</script>


You should be able to do that in place of your <script> tags above.

Give that a shot and let me know how it goes!

--
It's all in the reflexes.
Genius. Just a simple test right now, but no more errors in my dev console, and it's actually creating a cookie with the right expiration.

Thank you!! You're the bleeping man!

--
Ieyasu - Organizer, Ex Cineribus
Excellent!

Glad that worked!

--
It's all in the reflexes.
Sorry to necro such an old thread.

This has been working fine on my site (using a modified version of the Guild Wars template), but I get the following error using the same code in the Star Wars: Coruscant template:


Uncaught ReferenceError: jq_preload is not defined

Can this be fixed?

--
Ieyasu - Organizer, Ex Cineribus
Looking at your code, I'm seeing a crash before it gets to the jq_preload portion. It's crashing in the event formatting portion (probably due to the lack of an upcoming event).

You could either wrap that whole thing in a try-catch block to prevent it from breaking scripts on the rest of the page.

--
It's all in the reflexes.
Quote by Chops
Looking at your code



It's not "my" code. The only thing I did to the layout.html was add the script block you suggested above to load jquery.cookie.js.

Absolutely nothing else has been modified.



--
Ieyasu - Organizer, Ex Cineribus
Ha! Sorry, I didn't mean it to sound accusatory, but I realize that's totally how it came across.

Let me see what I can uncover.

--
It's all in the reflexes.
I didn't mean to sound defensive, just wanted to be sure we're all clear and on the same page. I also know that you don't officially support advanced layouts and such, so I try to keep my problems as simple as I can.

All I want right now is to load the plugin. If my script/code sucks, then I fully accept responsibility, but I think this one is out of my hands.

--
Ieyasu - Organizer, Ex Cineribus
Alrighty, I've found the cause. That block with the jq_preload call, go ahead and put that *after* the closing </head> tag. The Advanced Layout parser automatically inserts the dkpsystem.js script at the end of the </head>.

--
It's all in the reflexes.
Beautiful, thank you! It's working perfectly now.

I'm going to go break some more templates now and do a followup post

--
Ieyasu - Organizer, Ex Cineribus


[Back to Index]  [Top of Thread]