Hey
One of the great advantages of DOM-based templates (the native mechanism) is that existing DOM nodes remain in use and KO and just mutate those DOM elements without destroying unrelated aspects of their state. String-based template engines suffer from replacing whole areas of the DOM on each change, destroying any state not managed in your viewmodel.
Options:
1. Manage all state in your viewmodel, so that whatever part of the DOM is reconstructed, it comes back in the desired state. This is the MVVM-pure approach, but sometimes it's highly inconvenient.
2. Or, split your template into nested subtemplates, and then use the "template" binding to render each nested template. KO will only re-render the innermost nested template that is affected by a viewmodel change, so other DOM state will be preserved. This was the best approach before KO got its native DOM-based template engine in version 2.0.
3. Or, use KO's native DOM-based template engine, where it already is able to preserve unrelated DOM state :)
I guess you have some reason not to do #3, otherwise you would already be doing so. But could you clarify the use case? String-based templates are just not as convenient in general.
Steve