Read more

Data-Driven Templating in One Line

A quick snippet for this happy morning. Actually I’m going to format it so its a couple of lines…

var html = "<li><a href='{profileUrl}'><img src='{photoUrl}'/> {name}</a></li>".replace( /\{([^\}]+)\}/g, function(matches, name) {
  return store.getValue(item, name); 
});

Read the rest of this entry »

Read more

Extending a widget to make it data-aware

In the cookie about dojo.data, I extolled the virtues of data-driven widgets, and how much I loved them. However, there are times when the widget you want to use is not data-aware. This tutorial will step you through how to quickly and easily add data capability to a widget.

Read the rest of this entry »

Read more

Demystifying dojo.data

I have a love/hate relationship with dojo.data.

I absolutely love the way that it simplifies my life. While it’s not quite as “magic” as dojo.hitch(), things “just work” when I use it. Many of the dijit widgets support being tied to data stores. The drop-in replaceability of the stores is another great benefit. When working on large projects, it is very helpful to have something to work with on the UI side while the server-side is still being developed. One solution is to do this:

Read the rest of this entry »