Calling .trigger("click") That Is In Javascript Code Returned From An Ajax Call
What i would like to do is trigger a button's click event from within a view that gets returned from an ajax call. This process works fine in a pc browser such as chrome but not so
Solution 1:
Try adding the touchstart
event along side the click
event.
$("#bt1").trigger("touchstart click");
Solution 2:
you may need to implement touch events on mobile. Take a look at this SO answer:
If you cannot change what comes back from the server then you can listen for a click event and trigger a touch event.
Good luck, Mike
Solution 3:
It cannot find the button since the javascript code and the button element is being created programatically, try:
$(document).find('#bt1').trigger('click');
or
$(document).find('#bt1').each(function(e) {
e.trigger('click');
}
or, better:
success: function (data) {
$('#somediv').html(data).promise().done(){
$('#bt1').trigger('click');
});
}
Post a Comment for "Calling .trigger("click") That Is In Javascript Code Returned From An Ajax Call"