In case a form in a popup is reloaded (not done yet), extra javascript is not loaded.

In "popups.js" file I added the following lines, in the function "Popups.formSuccess":

if (!done) { // Not done yet, so show new page in new popups.
    Popups.removeLoading();
    Popups.openPathContent(data.path, data.title, data.messages + data.content, popup.element, popup.options, popup.parent);
    //PATCH 02/06/2011 - Inline JS not being loaded in case of form fail
    var inlines = Popups.addJS(data.js);
    Popups.addInlineJS(inlines);

Comments

drewish’s picture

Status: Patch (to be ported) » Needs work

I'm not quite clear what you're changing. Would you mind providing a patch to highlight the differences?

tugis’s picture

Basically I'm adding these two lines:

var inlines = Popups.addJS(data.js);
Popups.addInlineJS(inlines);

to the function I mentioned above. Those are the lines needed to load the JS into the popup. I'm sorry but I'm not used to create patch files. I have to learn that some day :/

mattcasey’s picture

I needed this, thanks! I am using a 'donePath' to get Popups to work with Contact Importer and Invite. I am using the hook_popups() function:

/**
 *  Implementation of hook_popups().
 *
 * This implements hook_popups, defined in popups_get_popups.
 * See the comments in popups_add_popups for explination of the options.
 * Adding popup behavior to the core admin pages has been moved to popups_admin.
 *
 * @return: Array of link selectors to apply popup behavior to.
 *          Keyed by path or form_id.
 */ 
function contact_importer_popups() {
  return array(
    'invite' => array( 
      'a.contact-importer-link' => array(
		'doneTest' => 'invite',
	  ),
    ),
  );
}
vivek.saurabh’s picture

That's really good, but how can I add the theme's JS to popup window, because I am loading a whole form in the pop-up but the JS is not getting into.

mattcasey’s picture

vivek, how are you adding your JS? I use drupal_add_js() In my theme's template.php, and it also may help to declare your code with Drupal's Behaviors if you are not already.

vivek.saurabh’s picture

Hi mattwad,

Thanks for your response, I switched my self to modalframe module and that worked like a charm.
I figured out that the, problem is with the CSS but not sure what exactly is the problem.
My requirement is to load the whole content of a form (a multi-step form) in a pop and that is achieved by the modal frame window.