Friday, April 20, 2012

You Never Go Full Retard

To paraphrase a line from Tropic Thunder, I've gone full retard with my usage of Dojo widgets.

It's not retarded, though. It's one of the proper usages.

Dojo seems to have two ways of doing their widgets. The first, and original way is by putting mark up in the HTML to denote the type and any properties. This is parsed at runtime.

The second way is complete programmatic insertion. Your HTML is a series of div tags with ids, and everything else is created and inserted with Javascript.

Up until now, I've been doing a combo of the two. I'd rather generate regular HTML from my back end framework (CakePHP), and then in the Javascript, identify elements to become Dojo widgets by id. The trouble with that approach is that Dojo is unprepared for it, and doesn't replicate some of the properties on the native element (like name) on to the newly created Dijit HTML.

It'll only be a matter of time before I get sick of adding the Dojo data-dojo-type attributes to my CakePHP form elements, and create a DojoFormHelper to default them for particular types of elements.

No comments:

Post a Comment