71104 / jquery-handlebars

A jQuery plugin to render Handlebars.js templates into elements
http://71104.github.io/jquery-handlebars
MIT License
100 stars 39 forks source link

Render if DOM changed. How? #14

Closed diwms closed 10 years ago

diwms commented 10 years ago

I use this great extension in one of projects. And it's work fine, if render template for a loaded DOM. But, how about situation when DOM is changed? For example, load part of page via ajax.

In my case, I want to render handlebars when user click. My code is:

$(function() {
$('#content').on('click', '#button', function(){
//Show content with new selector!
$('#messages').show();
//This don't work. Why?
$('#messages').render('messages');
})
});

Thanks for solution!

71104 commented 10 years ago

What about this?

$(function () {
    $('#button').on('click', function () {
        //Show content with new selector!
        $('#messages').show();
        //This don't work. Why?
        $('#messages').render('messages');
    });
});