I have a problem with button click does not firing when it dynamically created,
I know, here is the solution.
Question is this:
I am using SignalR. I must declare click event (to call some hub method) when chat hub is started. Please see below
button click works in this situation
$(document).on('click', "#chatlist li .gobtn", function (e) {
var id = $(this).closest("li").data("message-id");
});
But i should call it from here
$.connection.hub.start().done(function () {
//button click not fires here but it must be here
$('#chatlist li .gobtn').click(function () {
var id = $(this).closest("li").data("message-id");
chat.server.sendAnswer(id);
})
})
Please help if you have any idea to solve it.