Trigger MVVM click event manually

2 posts, 1 answers
  1. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 20 Apr 2013 Link to this post

    Hi,

    I have a scenario where I am trying to capture the enter key and trigger a bound click event for a view model.  The javascript is as follows:
    $form.on("keydown", function (e) {
            if (e.keyCode == 13) {
                $("#mybutton").trigger("click");
                 
            }
        });
    and  mybutton is bound as such:
    data-bind="click: AddPerson"
    and the view model has a property named "AddPerson" that works fine when clicking the button, but does not work when issuing a jquery trigger("click")

    Any ideas?

    Thanks,
    David A.


  2. Answer
    Alexander Valchev
    Admin
    Alexander Valchev avatar
    2895 posts

    Posted 23 Apr 2013 Link to this post

    Hello David,

    Thank you for getting in touch with us.
    I tested a similar scenario in this sample page, but did not manage to reproduce the behaviour. Could you please check my sample and let me know what I am missing?

    Regards,
    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top