How do I use event.preventDefault with KnockoutJs click event handlers?

前端 未结 2 619
无人共我
无人共我 2021-02-18 12:57

I have the following table row as a script template in KnockoutJs:

    

        
2条回答
  •  旧巷少年郎
    2021-02-18 13:16

    If you have jQuery referenced, then you can safely call e.stopImmediatePropagation(); in your handler, as it is passed the jQuery event object. If you are not using jQuery, then you could still do something like:

    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();
    

    http://jsfiddle.net/rniemeyer/mCxjz/

提交回复
热议问题