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 in a mobile browser. (i am using both jquery and jquery mobile).
(there is a lot more code involved in this but i have removed it for clarity)
I have a button in my html page like so.
<input type="button" id="bt1" value="" />
It has an onclick event listener on it defined somewhere else.
I have an ajax call that calls a php script like so:
$.ajax({
url: 'blah.php',
type: 'get',
data: {
id : $('#field').val()
},
dataType: 'html',
success: function (data) {
$('#somediv').html(data);
}
});
It returns "data" which is a segment of html with inline javascript. It containts the following code:
<div>
<script type="text/javascript">
$(document).ready(function () {
$("#bt1").trigger("click");
});
</script>
</div>
What ive noticed is that the trigger event will not be fired when used in a mobile. but works fine in pc.
Is there a different in the DOM when dealing with mobile that it prevents a trigger("click") from working if the object is outside the view?