jquery - Transparently binding focus handlers to new text inputs added by Knockout.js -


I'm using Knockout.js to create most of my UI and I have a streamlined way of selecting text Looking back at any input [type = text] on focus I have done such a thing in the past:

$ ('input [type = text]'). Click (function () {$ (this). Select ();});

But under the knockout paradigm, new input is being created and removed in response to the model changes of my thoughts. I do not want to do too much procedural stuff to force handlers again for new elements, I do not want to force clicks for every input input in my template, and I really do not want to use performance and other drawbacks Due to the whole document see jQuery's Live.

These inputs can be displayed at all levels in my template hierarchy, to respond to changes in the model of my thoughts and to transparently adopt the child's input in any of the new DOM structures created by Knockout Is there a clean way to hook?

You can write your own custom binder which does this for you, look at how Do it. You can increase the value of : binding and adding a part of focusing yourself, this should do the trick. You will need to replace all existing value binding with your custom one, where will be required.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -