I was planning on writing my first enquiry on how to do something in dojo, but just before I pressed the submit button, I thought I’d look into one more thing and as the saying goes – “it’s always in the last place you look” (probably because you stop looking after you find whatever it is you’re looking for).
So the problem I had was that I wanted to load a datagrid inside a contentPane in a pet project my newbie friends and I are using to sharpen our Zend Framework skillz.
I’ve been idle (and will continue to be for the rest of the year) so all my tickets are pretty much at a stand still. This included a ticket which reports that a remote datagrid does not load properly in chromium / google chrome, but loads fine in Firefox. But seeing as I have a few hours to kill from being idle (development wise, but actively looking after family) , I thought I’d do an idle search into why this was happening. Dojo could not possibly have a bug, there must be some magic attribute that needed to be set which would make it all better.
A couple of them mentioned “executeScript” attribute, but that was from ages ago, so I tried it a couple of times to no avail in dojo 1.5 then gave up looking for answers that use executeScript attribute.
Again. I can’t help but feel that I’ve been left high, dry and wanting to put my fist through my laptop. This was not going to be productive, so I thought I’d make a post on the dojo community mailing list instead.
After reading this post, it was clear.
This is what happened and why my remote datagrid did not load in the contentPane.
- I use Zend Framework Dojo view helpers – since it was how I got introduced – well, thrown into the fire, really, of the dojo toolkit:
- Fancy schmancy tab containers
- contentPane containers which made it a breeze to load remote content
- a fabulous platform for an RIA!
- Zend_Dojo_View_Helper_ContentPane uses dijit.layout.ContentPane; this minor detail is abstracted from the developer using the ViewHelper to create contentPanes.
- The dijit.layout.ContentPane will not execute any script blocks you have inside it. It was a lot of hassle trying to figure it out.
- What I really needed was the dojox.layout.ContentPane and _not_ dijit.layout.ContentPane which was provided by default by the ContentPane view helper.
- As a quick test, I changed the dijit and module attributes in the Zend_Dojo_View_Helper_ContentPane view helper and…
- There it was! A fully firing remote script in a ContentPane.
I swear there was a f*cking chorus of angels behind me singing with angelic voices “ahhhhhhhhhhh you f*cking goooooot iiiiiiit fiiiinalllllllyyyyyyyyyyyyyyyyyyyyyyyyyyy ahhhhhhhhhhhhhh” a halo radiated above my monitor and I was levitated into 3d space like the Rotate Cube effect on my ubuntu desktop environment.
What I’ll be
Moral of the Story: Use dojox.layout.ContentPane instead of dijit.layout.ContentPane
So to conclude, I’ll state it again: to load remote scripts into a contentPane, you need to use dojox.layout.ContentPane which has executeScripts enabled by default and not dijit.layout.ContentPane which does not have this option.
I suppose I could have just told you that you needed to use dojox.layout.ContentPane rather than dijit.layout.ContentPane, but then I couldn’t have dragged you through all the sh*t I went through to find it. Story of a developers life I suppose. Days of research and trial and error only to deliver one line of code.
Back to idling!
Till next time.
- Project Chronus: a Zend Framework/Dojo/Doctrine Project Quietly Launched