Skip to content Skip to sidebar Skip to footer

Events Called From Inside Another Function Jquery With Underscore Template Doesn't Work

I have a function which i used to add elements to a list, I want to have events run on interaction with this list, e.g. click. If I do it using the document object it works well ho

Solution 1:

are you shore that template() returns a element. if it returns a string (witch most template system do) that click event wont work.

also there's syntactic errors with not closing the click method.

Solution 2:

so with the help of megakorre this is the answer.

this.template = _.template($('#fileListEntity').html());
var li = $(this.template({name:doc.name}));
$(parentElement).append(li);

li.click(function(e) {
   alert('click');
});

Post a Comment for "Events Called From Inside Another Function Jquery With Underscore Template Doesn't Work"