Dot Net Mafia

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

Not Necessarily Dot Net

Selectors in Dojo

Selecting elements in dojo is really a very tiny piece of what it does.  It uses CSS 3 selectors.  If you haven't looked into them, check out CSS 3 selectors explained. It's a little disheartening, because IE still doesn't support most of these features (the IE 8 beta seems to have limited and buggy CSS 2.1 support), but dojo does.

Actually, anything I write about dojo selectors would be redundant.  Glance over the list at Dojo Selectors to get an idea of just how flexible and powerful this approach is. Some of the comments on the page tell you that it definitely isn't 100%, but it's still pretty impressive.

 Just to stay parallel with Kyle's post, though, here are a couple of examples:

// Set the text color of the element with an id of "one" to blue:
var one = dojo.query("#one");"color", "blue");
// Give all div elements with class foo a red background
var foo = dojo.query("div.a");"backgroundColor", "red");
/* Take everything that has an attribute custom with a value of whosit and give it a border:*/
custom = dojo.query("*[custom='whosit']");"border", "medium double black");

There really isn't much significant difference between dojo and jquery on this front, except that jquery uses its magic $ function, and dojo loops through selected elements automatically, when you're using it this way.

Edit: It strikes me as a little ironic that I decided to write this just now, because I just found out that dojo released version 1.2 today.


No Comments

Leave a Comment

2018 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems