11 ms·
I think one of the biggest reasons this is hard to do is because you end up having the same logic in two places. You have to keep the initial $.html() and the i
by ianstormtaylor 14y ago
I think one of the biggest reasons this is hard to do is because you end up having the same logic in two places. You have to keep the initial $.html() and the incremental changes consistent.
Or you could have the incremental changes follow the first call t $.html(), but then you always have to add those in each render and it gets ugly there too.
If you have other ideas though I'd love to hear 'em.
- kpozin 14y agoThe second of those is exactly the approach I've taken in the couple client-side web apps that I've built. I initially generate and insert generic DOM fragments from templates, but only use the template to fill in values that I know will not change throughout the lifetime of the view (the "templates" often don't have parameters). After that, I use one code path both for the initial value setting and for subsequent updates. If I'm not mistaken, this is more or less the approach used in Knockout and AngularJS.