This is a migrated thread and some comments may be shown as answers.

Trigger MVVM click event manually

1 Answer 269 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
David A.
Top achievements
Rank 1
David A. asked on 20 Apr 2013, 07:24 AM
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.


1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 23 Apr 2013, 09:10 AM
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!
Tags
MVVM
Asked by
David A.
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or