jQueryObject

18 Jul 2010 - webdev cakephp

CakePHP moved from Javascript helper to a Js helper and they decided to add support Prototype/Scriptaculous, Mootools/Mootools-more, and jQuery/jQuery UI.  Out of the 3, jQuery remains the one I like most so far. I’m not an expert in it (yet :p) but its pretty nifty to work with. Sometimes when working with one or more libraries, the jQueryObject which is $ by default tends to clash with other libraries. CakePHP of course has code to deal with this, only is not publicly mentioned how to do it. I spent around 5 hours to discover how, and here it goes drum roll

    $js->JqueryEngine->jQueryObject = '$j';
    print $html->scriptBlock('var $j = jQuery.noConflict();',
        array('inline' => false));

When you look at the code using firebug, you would now see the jQueryObject changed to $j. I’ve suggested a section to the book for this and I’ve also modified some of the documents for stuff that I found helpful.