Re: [KnockoutJS] Knockout.js - every click databind called twice... make this pain go away please....

362 views
Skip to first unread message

Gunnar Liljas

unread,
Dec 12, 2014, 10:36:03 AM12/12/14
to knock...@googlegroups.com
..and every post sent thrice! ;)

.NET 4.5, MVC5 and WebApi2 can not reasonably have anything to do with this. Any way you could possibly show us the problem "in action"?

/G


2014-12-12 7:41 GMT+01:00 <rdtx...@gmail.com>:

I have been trying to debug this for days with no solution.


I have an MVC5 app and using Knockout 2.3 and Jquery 1.10.    Whenever I click a button in my view's html (not in a form, just a button that is type="button" or "submit"), and that button's  click is  databound to a function in my viewmodel,  that viewmodel function gets called  twice??  I see the debugger shows that as well as Fiddler.   

 I set clickBubble to false... does not make a difference.  I stepped through the debugger and  KO properly sets   the e.prevent... parameters to false...


Any ideas?  Please, if  the suggestion is to use a different version of KO or Jquery,  please let me know you have actually tested those versions work with.net 4.5,  MVC5 and WebApi2.  Otherwise I am down another rabbit hole.  


Thanks in advance

--
You received this message because you are subscribed to the Google Groups "KnockoutJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to knockoutjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

larryno...@gmail.com

unread,
Dec 30, 2014, 5:02:40 PM12/30/14
to knock...@googlegroups.com
Use bind, passing parameters to the bind method:
 

data-bind="click: $root.myFunction.bind($data, $data)"

 
Reply all
Reply to author
Forward
0 new messages