I'm using Knockout.js to build most of my UI and I'm looking for a tidy way to select the text in any input[type=text] on focus. In the past I've done things like:
$('input[type=text]').click(function() { $(this).select(); });
But under the Knockout paradigm, new inputs are being created and removed all the time in response to my view model changes. I don't want to have to do too much procedural stuff to re-bind handlers to new elements, I don't want to add a click binding to every single input instance in my templates, and I don't really want to use jQuery's live to watch the whole document due to the performance and other drawbacks.
These inputs can appear at all levels throughout my template hierarchy. Is there a clean way to hook into any new DOM structures having been built by Knockout in response to my view model changes and wire up child inputs transparently?