Great module, I have one question.

If I load a form with automodal, how can I refresh the page after the form submit? This wouldn't be the case for all pages loaded with automodal, but maybe for some..

Thanks

Comments

rc2020’s picture

Yes, I am also interested in this.

kristen pol’s picture

I need this too. I wasn't able to get refresh to work with the popups module so was hoping it would work with automodal.

Kristen

lelizondo’s picture

@kepol actually with popups it's really easy, all you have to do is change the link class to something like popups-form-reload (it's in the README)

rc2020’s picture

@lelizondob, that is a good suggestion and I thank you for it, but automodal is infinitely superior to popups module because of the formsapi support...is there a way to perform the auto-reload with automodal?

Thanks!

lelizondo’s picture

Not that I know. There's plenty of examples but I haven't had the time to analyze them and Javascript is not 'my thing'. I don't know if the owner of this module could give us a hand with this.

mauro72’s picture

I found a way to reload the page using automodal, is not 100% because you have to add some code into the the automodal.js file.
Anyway, the idea is to uncommnet the onSubmit parameter in the automodal.js file and create the functions that controls what to do when the form is submitted.

    function onSubmitCallbackCustom(args, statusMessages) {
      // Display status messages generated during submit processing.

      if (statusMessages) {
      }

      if(args && args.reload){
	setTimeout(function() { window.location.reload(); }, 100);
      }
    }
    
    var settings = {
      autoResize: true,
      autoFit: true,
      width: 600,
      height: 400,
      onSubmit: onSubmitCallbackCustom 
    }

The args.reload value is passed trough a custom form_submit function that we have to create in a custom module, in my case the form id is ct_tickets_node_form,

  $modal = $_GET['modal'];
  if($form_id == 'ct_tickets_node_form' && $modal == 'close') {
	$form['#submit'][] = 'modalframe_tickets_form_submit';     
  }

I added the ?modal=close, to the href attribute of the link that triggers the automodal event
where the function modalframe_tickets_form_submit is

function modalframe_tickets_form_submit($form, &$form_state){
  // Ignore preview requests. Close dialog only when user clicks "Save" button.
  if ($form_state['values']['op'] == t('Save')) {  
    modalframe_close_dialog(array('reload' => TRUE)); 
  }
}

with this when you save the node form, the modal window is closed and the page is reloaded. One thing to solve is to achieve this behavior without hacking the automodal.js file.

Aldus’s picture

did someone come out with a less invasive solution?

marcel66’s picture

I'm not very sure but try to change in modalframe_example.js :

function onSubmitCallbackExample(args, statusMessages) {
...
location.reload();
}

iTiZZiMO’s picture

thx for the solution but unfortunately this function doesnt work for me mauro72 :


(function ($) {
  Drupal.behaviors.automodal = function () {
    var selector = Drupal.settings.automodal.selector || '.automodal';
    

      function onSubmitCallbackCustom(args, statusMessages) {
      // Display status messages generated during submit processing.
      
      if (statusMessages) {
      }

      if(args && args.reload){
setTimeout(function() { window.location.reload(); }, 100);
      }
    }


    var settings = {
      autoResize: true,
      autoFit: true,
      width: 600,
      height: 400,
      onSubmit: onSubmitCallbackCustom     
      
    }
    
    $(selector).click(function () {
      settings.url = $(this).attr('href') || '#';
      
      if (settings.url.indexOf('?') >= 0) {
        settings.url += '&'
      }
      else {
        settings.url += '?'
      }
      settings.url += 'automodal=true';
      
      Drupal.modalFrame.open(settings);
      
      return false;
    });
  }
  

   

})(jQuery);

any other ideas?

here is my submit function

function <mymodule>_close_form_submit($form, &$form_state) {
    modalframe_close_dialog(array('reload' => TRUE));
    return;
}

using pressflow 6.17.85 and jquery_ui 1.7.3 and automodal

thx for helping!

mfer’s picture

Status: Active » Fixed

in automodal_add() pass in automodalReload as TRUE and the page will refresh.

This went in as part of an extensible behavior for onSubmit handling.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

lelizondo’s picture

This is my working example, thanks.

<?php
function mymodule_automodal_alter(&$settings, &$selector) {
	$settings['automodalReload'] = TRUE;
}
?>
rwohleb’s picture

Looking through the automodal JS it looks like you can handle this just with URL parameters. The automodal settings code just adds these parameters to the URL passed to modalframe anyways.

Before:

<a class="automodal" href="/foo">foo</a>

After:

<a class="automodal" href="/foo?automodalReload=true">foo</a>
gmclelland’s picture

Noob question, but how do you construct a link like <a class="automodal" href="/foo?automodalReload=true">foo</a> using the drupal l function? Everything I try doesn't work.

Thanks,
-Glenn

keesee’s picture

Love this module. I've used it for displaying content for some time and it works great. I recently used it for 2 forms as it seems to be working work. The one thing that bugs me is that it shows you a flash of content in the iframe before closing and reloading the page. has anyone found an elegant solution to keep this from happening?

Thanks in advance.

gmclelland’s picture

Anybody looking for a solution to #14, the answer is here:
http://drupal.org/node/1070722#comment-4151078

Hope that helps someone,
-Glenn

zatarain21’s picture

Thanks a lot rwohleb (Post 13), that solution works for me.

An easy way to use is make a view that list a post of cckcontent

Then in the header of the view write this:

<a href="/igcaav/node/add/namecckcontent?automodalReload=true" class="automodal"><b>Add content</b><a>

The result is cool, in this way the user create content in a modal frame and see the result in the list after post.