In the following scenario:
HTML
<a id="mButton" data-role="button" data-click="clickFn">myButton</a>
<asp:ImageButton runat="server" ID="aspButton" style="display: none"></asp:ImageButton>
SCRIPT
function clickFn(e) {
$("#aspButton").click();
}
The click event of “aspButton” is [almost] never triggered when I click on “mButton”. I have tried binding to the “mButton” touchend event but this also does not work.
How would I be able to use an anchor tag with the data-role=”button” attribute to fire the click event of an asp button? I am using the latest Kendo UI Mobile and latest JQuery.
Thanks!
Update
It works perfectly if I change my clickFn to the following:
function clickFn(e) {
setTimeout(function () {
$("#aspButton").click();
}, 400);
}
This is leading me to believe Kendo UI Mobile’s event handling may have something to do with this that I am unaware of. According to their forums, the Kendo UI Mobile View transition speeds is 400ms. Further, setting the timeout to even 399ms fails to execute the aspButton click event successfully.
Hope this helps.
Are you sure if the ‘aspButton‘ is actually the id of the widget on the client side? (I personally have doubts about this)
You can try to trigger the event with the trigger method jQuery provides.