Avoiding $ conflicts in jQuery

In a previous post we looked at how we could integrate the ZFDebug toolbar into the Zend Framework – what a great tool that is! However at the end of it’s call it called:


Which basically clears the “$” from being linked to the jQuery framework. When that toolbar was enabled we found that we would get javascript errors on some pages due to the scripts not recognizing the “$”.

When creating plugins, it is a better practice to wrap all your functions in the following manner to avoid this problem:

    //Your fancy plug-in code

This is creating a wrapper function for your code that passes jQuery as the parameter to be assigned to the “$”.


Saturday, July 3rd, 2010 jQuery

Leave a Reply

You must be logged in to post a comment.

[ad code=1 align=center]