Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reposition jQuery Mobile popup after content change

I`m using jQuery Mobile (1.3.1) to display a popup (screen centered). Depending on the user actions, some content gets inserted into the popup via AJAX. This works fine, but there is one problem: Once the content is injected into the popup its size changes, but the position is not updated. As soon as the window is resized, the popup position gets refreshed, but so far I did not find a way to trigger this action manually.

Declaration of the popup:

<div id="MoveFolderPopup" data-role="popup" data-position-to="window" style="min-width: 20em">

Some things I already tried to reposition the popup to the window center (including a quick view to the popup widgets source code for some internal, undocumented events):

$('#MoveFolderPopup').trigger("reposition");
$('#MoveFolderPopup').trigger("_reposition");
$('#MoveFolderPopup').trigger("_handleWindowResize");
$('#MoveFolderPopup').trigger('refresh')
$(window).trigger('resize');
$('#MoveFolderPopup').popup('open');
$('#MoveFolderPopup').trigger('updatelayout');

I do not have many experiences with JavaScript and just don`t have any more ideas for this problem ;) Could someone please help me? Thanks!

like image 403
orbitluke Avatar asked Jun 17 '13 10:06

orbitluke


1 Answers

$("#MoveFolderPopup").popup("reposition", {positionTo: 'origin'});

or

$("#MoveFolderPopup").popup("reposition", {positionTo: 'window'});

in this case either will do, because data-position-to="window"

like image 103
adin Avatar answered Oct 20 '22 13:10

adin