SAEF’s annoying default
02 May 2012 at 1:38 pm
I love the Expressionengine CMS and these days I do a lot of projects with it. Today I lost an hour hunting for a stupid bug, due to a strange default. In my current project I needed a tooltip, so I did what I’ve done in dozens of projects before: I added jQuery + jQuery Tools at the top in addition to my own “ready-function” that would init the tooltip. It didn’t work and it took me a long time to figure out what this error meant:
Uncaught TypeError: Object [object Object] has no method 'tooltip'
It looks like there’s a problem finding the object, right? All the links I found led to things about the incorrect loading sequence of the Javascript files, but I knew that wasn’t the fault here. I DID include the files in the right order. It worked standalone, but not in my EE templates. In other words - there had to be something inside EE that caused the problem? Strange!
A very nice module that I’ve only had a need for recently is SafeCracker (formerly called Stand Alone Entry Form or SAEF for short). It turns out - even if you don’t use any features that require it, SAEF will include it’s own version of jQuery and JQuery Tools? The code will be embedded at the bottom of your form, so even if you have everything in order at the top of the file, it’ll be overwritten at the bottom.
Fixing the problem is as easy as adding a tiny snippet to your Safecracker tag
{exp:safecracker ... include_jquery="no"}
This is 2012 and JS libs are updated on a weekly basis to fix browser bugs. Auto-incuding unrequested features based on outdated libraries is NOT the way to go (as default). Hope this post can help others to not spend time on this…