I'm using Nodereference_url and Modal Frame API to open a modal frame to write a review on a product. The product is the parent, the review the child page.

After the review is added in the modal frame, I want the modal frame to be closed after submitting and I want the parent (product) page to be reloaded to show that a new review is added. If I don't use the modalframe_close_dialog, the parent is opened in the modal frame. If I do use modalframe_close_dialog(array()), the modal frame is closed. But I want the parent page to be reloaded and I would like that page to show the message that the review is added.

Anyone knows how to do this?

Comments

pcbos’s picture

I've added the following to the hook_form_alter:

  if ($form_id == 'review_node_form') {  
  $form['buttons']['submit']['#submit'][]= 'modulename_form_submit';
  }

Then I've added a new function:

function modulename_form_submit($form, &$form_state) {
  // Ignore preview requests. Close dialog only when user clicks "Save" button.
  if ($form_state['values']['op'] == t('Save')) {
    // Tell the parent window to close the modal frame dialog.
   modalframe_close_dialog(array());
  }
}

I would like to know what I can put in the array to call the OnSubmit element of the API.

Still nobody that has the answer?

rakeshakurathi’s picture

any possible solutions please

rakeshakurathi’s picture

can any one help me to do this please.

erik.ahlswede’s picture

Call window.location.reload(); in your onSubmit event handler

EDIT: adding example


function onSubmitCallbackLogin(args, statusMessages) {
      // Display status messages generated during submit processing.
    	if (statusMessages) {
            $('.modalframe-example-messages').hide().html(statusMessages).show('slow');
          }

		if (args && args.message) {
			// Provide a simple feedback alert deferred a little.
			setTimeout(function() { alert(args.message); }, 500);
		}
		
			setTimeout(function() { window.location.reload(); }, 100);

      
      
    }

dropchew’s picture

This will reload the page even if closing the modal box without any submits.. any other thoughts?

erik.ahlswede’s picture

If it is in the Submit event handler, it should only refresh on submit.

xtfer’s picture

Unfortunately, this doesnt quite work, as the Modalframe API defines any close event as "onSubmit", not just the submit action.

netourish’s picture

Thank you, very much for the above information. This has worked for me.

In my requirement, the parent page is a list containing two columns name and address, and a link "Add new".

On clicking the "Add new" link, a modal frame is opening up and on submitting the modal frame, the parent page is getting refreshed with updated information. (I am really thankful to you for achieving this.).

After this a status message is getting displayed on the parent page and it disappears once the parent page gets reloaded. (It is quite obvious.).

But,my requirement is to display a status message on the parent page after it gets reloaded.

Any or all guidance/suggestion/help is greatly honoured.

Thanking You,
Pradeep

pgrond’s picture

subscribe