Home › Forums › JavaScript › jQuery not responding once I move it to wordpress
- This topic is empty.
-
AuthorPosts
-
January 23, 2011 at 6:07 pm #31355Historical Forums UserParticipant
Working… http://build.aaronheine.com/wp-content/themes/Starkers/demo/rez.html
Not working… http://build.aaronheine.com/about/
Same thing.
Thanks
January 23, 2011 at 6:11 pm #64399Rob MacKayParticipantHey. Yea. It’s the way WordPress loads scripts to remove the problem of duplication and clashes between libraries.
have a look here:
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
or just wrap your jQuery in this document ready, instead of the default:
jQuery(document).ready(function($) {
January 23, 2011 at 7:23 pm #64392Historical Forums UserParticipantAre you saying jQuery is not working? It is, I tested it.
So I changed…
$(function() {
with
jQuery(document).ready(function($) {
but still not working.
January 23, 2011 at 7:26 pm #64375Rob MacKayParticipantYes.
If you have a read through the page I linked it might make a little more sense too :)
and here too:
http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/
January 23, 2011 at 8:44 pm #64302Historical Forums UserParticipantOk, it’s finally responding. But jQuery is not adding to the #mover.
This is some craziness!
January 24, 2011 at 8:06 am #64149Historical Forums UserParticipantI tried that. Not working.
The jQuert is adding the distance to the list items, just not the #mover.
January 24, 2011 at 11:27 am #64119clokey2kParticipantI have been staring at this one for some time now. Checking the script from ‘DOM ready’, comparing the scripts (and CSS :-) ). But now I have found it!!!
HTML 5 data- Attributes
As of jQuery 1.4.3 HTML 5 data- attributes will be automatically pulled in to jQuery’s data object.
You are including 1.4.2, so the ‘data-pos’ HTML attribute is ignored. So, either include a newer version of jquery or change:
jQuery("#mover").css("left", -($el.data("pos") * speed - 40));
to:
jQuery("#mover").css("left", -($el.attr("data-pos") * speed - 40));
BTW You can use ‘$’ to reference jquery while inside the :
jQuery(document).ready(function($) {
}I also don’t think you need to use the no-conflict mode of jquery. If you are still loading the script via the deregister/register scripting in the ‘function.php’, as it unloads WordPress’s warped version of jQuery (but leaves the original jQuery for admin pages!).
I could be wrong, on all accounts – but I have learnt a few things while playing :-p
January 24, 2011 at 7:10 pm #64071noahgelmanParticipantYeah, I had the same issue with this not working (although not on wordpress), you have to update to 1.4.3 in order for it to work
January 24, 2011 at 7:46 pm #64072Historical Forums UserParticipantYes! Thanks Clokey! Good things will happen to you this week.
I wonder why the following code pulls an older JQ library? Seems like it would pull the newest.
January 24, 2011 at 7:52 pm #64073noahgelmanParticipantI believe that links locally, you probably can just rip out that line and link straight to googles newest version and be fine. You should do that anyway.
January 25, 2011 at 3:58 am #64081Rob MacKayParticipantIt just links locally by default because WP comes “supplied” with a copy of jQuery.
http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Example
Shows how to pull it from the CDN :)
January 25, 2011 at 12:08 pm #80522clokey2kParticipantI posted this in response to someone else recently (I thought it was you @aaronheine), and I referred to it earlier but didn’t link it: https://css-tricks.com/forums/discussion/comment/40341/#Comment_40341
I use this script, it includes the deregistering of WP’s jQuery, pulling in the Google CDN version, and loading other plugins etc. The plugins loading based on dependancy aswell;
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.