//====================== Data ======================
var person = {
firstName: "Jeff",
lastName: "Friedman"
};
//====================== Helper ======================
// Parameterized computed observable helper function
function fullName(reversed) { ... }
// Declare dependencies
fullName.depends = ["#data.firstName", "#data.lastName"];
// For two-way binding of computed observables, provide a setter
fullName.set = function(val) {
// The this pointer is the view, so this.data is the current data item
$.observable(this.data).setProperty({
lastName: ...,
firstName: ...
});
//========== Register helper, or pass in as parameter ==========
// Register helper ...
$.views.helpers({
fullName: fullName
});
// ... or alternatively pass helper in as a computed template parameter:
$.link.personTmpl( "#details", person, { fullName: fullName});