Blog posts in: jquery

Change the execution order of $(document).ready()

If you use jQuery in development, you've almost definitely used $(document).ready(). $(document).ready() is a wonderful function that lets you run Javascript code as the page is ready to handle it. But one potentially frustrating aspect of it is that functions are executed in the same order they're passed in, and jQuery doesn't let you choose which functions run first.

Usually, this is fine, but every once in a while, you really want your function to run before another function. For example, if your page is running jCarousel or Google Maps, or any other library that changes the markup of your page, you might want to do some processing before they get a chance. With the traditional $(document).ready(), you'd be out of luck.

Adding Functions to jQuery

jQuery comes with a lot of functionality right out of the box, and even more in the form of plugins, but sometimes you run into situations where the function you want doesn't exist. Or maybe you just want to create a shortcut for a set of functions you use often. Maybe you even want to write your own jQuery plugin, but you aren't sure where to begin.

Drupal.behaviors LADrupal Lightning Talk

I gave a short 5 minute lightning talk at the recent LA Drupal meetup.  I presented on using Drupal.behaviors rather than using $(document).ready().  It was quite a bit of information to fit in five minutes, but I believe I made it with a couple seconds to spare.  I've posted the slides here for anyone interested in looking them over.

Syndicate content