I have two pages,
On the first page there are images that the user can select. On the second page, the user has some info about the image he selected.
How can i get rid of this delay between pages ?
here is my code:
<div id='FirstPage' data-role='page'>
<div data-role='header'>
<h1>First Page</h1>
</div>
<div data-role='main'>
<a href='#SecondPage'>See second page</a>
</div>
</div>
<div id='SecondPage' data-role='page'>
<div data-role='header'>
<h1>Second Page</h1>
</div>
<div data-role='main'>
<div id='images'></div>
</div>
</div>
js:
var server = "https://myserver.com";
$(document).on("pageshow","#FirstPage",function(event){
// Get some images to select with ajax
});
$(document).on("pageshow","#SecondPage",function(event){
// Reset the images div to remove image duplication.
$("#images").html('');
// Get images
$.ajax({
type: 'GET',
data: image_id: image_id
url: server + '/Api/get_images.php',
crossDomain: true,
dataType: 'json',
success: function(response){
$.each(response.data, function(i, val){
$("#images").append("<img src="+ val.image_path +">");
})
},
error: function(error){
}
});
});
Try to use the "pagebeforeshow" event. You are reseting #image
after the transition animation is complete.
The "pageshow" event is triggered after the transition animation is complete.
The "pagebeforeshow" event is triggered before before the transition animation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.