2
votes

I have a jQuery click binding within a knockoutJS foreach, and it's not working. I believe that knockout is stopping the propagation.

Is there a way to make it work? I'm trying to avoid binding to click event with knockout.

1
Can you post some code? Maybe in a JSFiddle? By the way you should return true in your KO event handler to propagate the event. - nemesv
if you don't share your code it's going to be difficult to help you - Josep

1 Answers

12
votes

Without seeing any of the code, I can only assume that you are doing something similar to

$('element').on('click', function(e){});

To bind a click event to dynamically generated objects you need to have your click events like this

$('body').on('click', 'element', function(e){});