I have a confusing problem with centering a jQuery Mobile popup. When I click it the first time it is not centered and appears in the corner of my page. After closing it and opening it again it is suddenly centered.
This is my code:
$(document).on("pageshow",function(){
$('.image_link').on('click', function(event){
var id = $(this).children('img').attr("id");
$("#show_image_img").attr("src",sPath + "/view/images/" + id);
$("#show_image").popup('open');
$("#show_image" ).popup({ positionTo: "window" });
});
});
and this is my html code
<div data-role="popup" id="show_image" data-theme="c" class="ui-corner-all">
<div style="padding:20px 30px;">
<img id="show_image_img" src="" />
</div>
</div>
Does anybody have an idea how to solve this problem? I tried already various things like changing the pageshow
event to a pagebeforeshow
and so on.