Hello,

I'm new to Drupal, so please bear with me. I am trying to implement a modal frame for a popup form. I'm going off the writeup here:

http://drupal.org/node/700752

I'm trying to put a popup modal on a specific node, which will open up a webform. The webform's been created in its own module, and modalframe_child_js(); is called inside of the form (right before the return $form). In the node template (node-download.tpl.php), I've put the following:

modalframe_parent_js(); 
drupal_add_js('sites/all/js/download_request.js');

The contents of download_request.js are as follows:

(function ($) {
	Drupal.behaviors.documentRequestModal = function(context) {

		$('.doclink a:not(doclink-processed)',context).addClass('doclink-processed').click(function() { 
			Drupal.modalFrame.open({url: $(this).attr('href'), width: 800, height:600});
			return: false;
		});
	
	};
})(jQuery);

When I access the node, clicking on the link just opens the form up in a new window. In the node, the link to launch the form is given the class "doclink." When I look at the source code for the page, the class on the link hasn't been changed to "doclink-processed." I know that download_request.js is getting pulled in, I temporarily threw an alert in there to make sure it was actually getting loaded. I'm kind of at my wits' end here, so any help would be appreciated.

Thanks :)

Comments

markus_petrux’s picture

The not() selector needs a dot.

padkeemow’s picture

Still not working. :( Added the dot so that it reads:

(function ($) {
Drupal.behaviors.documentRequestModal = function(context) {

$('.doclink a:not(.doclink-processed)',context).addClass('doclink-processed').click(function() {
Drupal.modalFrame.open({url: $(this).attr('href'), width: 800, height:600});
return: false;
});

};
})(jQuery);

The anchor tag still shows up as having class "doclink" instead of "doclink-processed".

Edit: do I need to be calling documentRequestModal from the node containing the link for the modal?

markus_petrux’s picture

Nope. You need this is script present in the page that wants to open the modal frame. To see how its executioon flows and check the environment when that happens, you could try debuggimg with Firebug. There may be little things that are hard to see now, that could be easily catched in that way.

Also, make sure there's no syntax error, etc. See the colon in return: false;

padkeemow’s picture

Oop. Fixed that now. Still not doing anything, unfortunately. Firebug isn't finding any errors.

Does it matter where the import is done in the template file? This is what the template has right now:

<?php
// $Id: node.tpl.php,v 1.4 2009/07/13 23:52:58 andregriffin Exp $
?>

  <?php
    modalframe_parent_js(); 
	drupal_add_js('sites/all/js/download_request.js');
  ?>

<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">

  <?php print $picture ?>

  <?php if ($page == 0): ?>
    <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
  <?php endif; ?>

  <div class="content">
    <?php print $node->field_body_download[0]['value'] ?>
    <?php print $node->content['group_node_references']['group']['field_discipline_download']['#children'] ?>
    <?php print $node->content['group_node_references']['group']['field_profile_download']['#children'] ?>
    <?php print $node->content['group_node_references']['group']['field_client_download']['#children'] ?>

  </div>
	
  <div class="meta clearfix">

    <?php if ($links): ?>
      <div class="links">
        <?php print $links; ?>
      </div>
    <?php endif; ?>

  </div>

</div>

The import of download_request.js is being done at the top, right after the call to modalframe_parent_js. Does it need to be placed somewhere later?

padkeemow’s picture

Anybody? I still can't get a modal to pop up here.

padkeemow’s picture

Status: Active » Closed (fixed)

Update: issue fixed. A colleague was poking around in the download_request.js file, adding some console log statements to see where it was breaking. After deleting the log statements it mysteriously started working. Chalking it up to a weird whitespace issue.