Posts Tagged ‘javascript’

Buddypress jQuery is not defined error

December 16th, 2009

While developing a Buddypress plugin, I was running into a problem where none of my Javascript was working. Instead, Firebug was telling me: “jQuery is not defined”.  This was quite frustrating, as I could verify that the jQuery file was indeed, being loaded.  While a few other people received the same error for different reasons (corrupt files, etc.) I did not quickly find the solution for my problem.  Here it is:

Problem: Buddypress calls your plugin’s JS files BEFORE jQuery files.
This applies when you use the function wp_enqueue_script() – as you should.

Solution: Tell wp_enqueue_script your file depends on jQuery.
It turns out, wp_enqueue_script() takes a few optional parameters – the third being an array of other js files yours is dependent on.

Here’s how the call looks after the change:
wp_enqueue_script(’my-js-file’,'my-file-path.js’,array(’jquery’));

Viola!  Your js file is now loaded after jQuery and you’re good to go.

The Zen of CSS Design

December 7th, 2008
The Zen of CSS Design

The Zen of CSS Design

I recently finished The Zen of CSS Design. The book has a good display of creative website designs, and it’s good for providing inspiration. It organizes the content in an interesting way, where each chapter focuses on a single aspect of desgn: ie, layout, imagery, typography, etc.  Within each chapter, individual designs are dissected and evaluated as they apply to these design principles.

Unfortunately, I found much of the text to be cheesy and repetitive, not unlike what you would stick in a history paper to reach the word count your teacher asked for.  The author is at times ambiguous, and at other times attempts to wax poetic.

It suffers from an identity crisis that many web books do: It moves too fast for the beginner, and re-hashes the basics too much for the experienced. Myself being in the latter camp, and my eyes start to glaze over when I read how to use a “background-image” or “border” property.

Also, with many CSS books, it fails to acknowledge when compromises are necessary. There are times when it’s just plain better to use JavaScript or tables. As a working web developer with deadlines and budgets, you don’t have the luxury (burden?) of creating 10 lines of CSS and 3 divs just to avoid using a little 2 cell table.

Overall, I’m glad to have the book, but mostly for the eye candy rather than what it has to say.