Closed Marak closed 13 years ago
To give you some perspective, here is my current approach, I'm delegating in the map based on the tagName
.
weld(dom, data, {
map: function(parent, element, key, val) {
if(element.tagName === 'A') {
$(element).attr('href', val);
$(element).html(path.basename(val));
return false
}
element.innerHTML = val;
return false;
}
});
This feels a little wrong to me. If I'm in a large weld my delegation logic could start getting a little complex? Also, it would be nice if things like links and form inputs were a little more friendly to weld to. I've done a bit of work that might be useful here: https://github.com/flatiron/jsonForm/tree/master/lib/jsonForm/plugins
i believe the following will work.
weld(dom, data, {
alias: {
'a': function(parent, element, key, val) {
element.href = val;
}
}
});
Ahh! alias
, will try that next time. Thank you.
What's the best practice for welding links? I really don't want to use string concatenation, anywhere.
I'd to generate: 'hello' from JSON.