Is there any way to pass function to bind into jQuery template engine?
http://api.jquery.com/tmpl/
If I create HTML without template I would do it like this:
jQuery("<a>link</a>").click(function(){alert('hi!')}).appendTo( "#forms_container" );
how to do this with jQuery templates?
————EDIT
I found some library here
http://knockoutjs.com/documentation/template-binding.html
and seems it something like jQuery.live()
Is there any other ways for binding functions to templates, or this way is used as default mostly?
———–EDIT
Ok, then let it be .delegate. I think for my small task it will be enough, without adding more complexity with Knockout
Similar to Ian’s, but a bit different in implementation:
This means that all links in the forms_container will have that click event, no matter what changes. This differs from Ian’s (perfectly legitimate) use of
livein that it has a context, so events don’t need to bubble all the way up. You can accomplish the same thing usinglive(as of 1.4) if you give it context, but I preferdelegate‘s syntax.