Did anybody notice the new sitemap I did for the blog? Top-right, in the black part. Click on sitemap. Smooth! For those of you who don’t know, that’s jQuery. Okay, seriously, this is my first ever jQuery script because I love Prototype. I don’t know why I did that, since I could have done it with Scriptaculous. So, about scripts in WordPress… You all heard about the function wp_enqueue_script in WordPress, yeah it’s cool, but what if I want to use both Prototype AND jQuery? Yeah, sounds stupid, but what about having two different plugins installed. One that uses Prototype, the second one jQuery. Compatibility?
Took me quite some time to figure out how to use jQuery $() function in WordPress though. I really think that the man who came up with this is a genius. There’s a synonym for the $() function in jQuery called jQuery(). WordPress’ers must have removed the $() function for Prototype compatibility.
jQuery(document).ready(function(){ jQuery(".sitemap-click").click(function(){ jQuery("#sitemap").fadeIn("slow"); return false; }); });
So instead of $() we use jQuery(). Sweet.
Oh and I’m also glad that Skype on iPhone will be free and official!
Looks great, one suggestion though. Change .fadeIn to .toggle and remove the 'return false'. That way they can remove the box by clicking the same link.
Good thinking! Thanks I'll consider that :)
Thanks for this. I just upgraded to W2.8 and my jquery script stopped working and I couldn't figure it out, but this helped. Cheers.
You're welcome ;)
Hey! Great tip! Your sitemap action would be even *smoother* if the link was actually a toggle, so the sitemap could could be dismissed too.
Your code could be easily modified to do this:
<code>
jQuery(document).ready(function(){
jQuery(".sitemap-click").toggle(function(){
jQuery("#sitemap").fadeIn("slow");
return false;
},
function(){
jQuery("#sitemap").fadeOut("slow");
return false;});
});
</code>
Give'r a go!
Hey Evan, thanks. I might as well use fadeToggle.. I think =)
Looks great, one suggestion though. Change .fadeIn to .toggle and remove the ‘return false’. That way they can remove the box by clicking the same link.
I ran into a strange issue today. I wrote a plugin for jQuery that used the load events from jQuery attached to an image. This plugin worked perfectly in Firefox, Safari, and Opera on PC, Mac, and Ubuntu. The only browser that it had problems with was IE.
IE always has problems ;) IE8 is looking good though…
Thank you for this, I couldn't work out this problem I was having with wordpress but this solved my problems!