Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved this so I thought I'd leave a response for anyone else looking.</p> <p>Basically my problem boiled down to calling $.modal.close() when I shouldn't have been.</p> <p>Initially when I wanted to reload the dialog I called $.modal.close() and performed my reload inside of the onClose() callback. By calling $.modal.close() it would seem that I was stripping the close event handler and so when I reloaded the dialog things were breaking.</p> <p>To fix the issue I removed the reload request from the onClose() callback and just handled everything inside a regular function. When I was using the callback I was making use of the returned dialog object to perform animations. With this new approach I can achieve the same result by targeting $('#simplemodal-container') instead.</p> <p>TL;DR - The code below allows me to load new data into an open dialog via AJAX while also being able to re-size and re-position the dialog.</p> <p>Code to open a dialog:</p> <pre> <code> function pop_dialog(url, width, height) { $('div.modal').modal( { minWidth: width, minHeight: height, onOpen: function(dialog) { //Animate the overlay dialog.overlay.slideDown('slow', function () { //Make sure the contents of the dialog are showing dialog.data.show(); //Preload $('.dialog-preloader').show(); $('div.modal img.logo').show(); //Fade in preloader display and perform AJAX request dialog.container.fadeIn('fast', function() { data = ajax_page_load(url, false, false); //On success, show dialog contents if(data.statusText == 'OK') { $('div.modal div.container').html(data.responseText); $('.dialog-preloader').hide(); } }); }); }, onClose: function(dialog) { //Fade out the dialog dialog.container.fadeOut('slow', function() { //If we're closing the dialog, animate the overlay off. dialog.overlay.slideUp('slow', function() { //Clean up the mess. $.modal.close(); }); }); } }); } </code> </pre> <p>Code to 'reload' the dialog</p> <pre> <code> function load_dialog(url, width, height) { //Hide the dialog $('#simplemodal-container').fadeOut('slow', function() { //Hide the dialog contents and show preloader $('div.modal div.container').hide() $('.dialog-preloader').show(); //Set the new width $('#simplemodal-container').width(width); $('#simplemodal-container').height(height); $.modal.setPosition(); //Fade container back in with preload message $('#simplemodal-container').fadeIn('slow', function() { //Perform AJAX request to load new dialog data = ajax_page_load(url, false, false); //On success, show dialog contents if(data.statusText == 'OK') { $('div.modal div.container').html(data.responseText); $('.dialog-preloader').hide(); $('div.modal div.container').show(); } }); }); } </code> </pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload