Thursday, 29 October 2009 09:34

As part of a recent project, I needed to open a modal window using Javascript. Here's how I did it.

First, I made sure the modal behavior was loaded:

JHTML::_('behavior.modal');

Then, in my Javascript, I created a new element to house all of my dynamic content (this could also be a hidden div, if needed). Once I had that, all I had to do was pass the MooTools reference of that object to SqueezeBox, and open.

var newElem = new Element( 'div' ).setText( 'demo' );
SqueezeBox.setContent( 'adopt', newElem );

Now, had I wanted to open an external resource with an iframe handler, I could use the following:

SqueezeBox.setContent( 'iframe', 'http://jeffchannell.com' );
Last Updated on Monday, 07 December 2009 12:44
 
Comments (2)
1 Thursday, 04 February 2010 15:11
Fronky
Thanks a lot!!
Simple and working
2 Monday, 06 December 2010 16:29
JSRR
Thank you. Really helpfull information. :)

Add your comment

Your name:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:

The Joomla!® name is used under a limited license from Open Source Matters in the United States and other countries. Jeff Channell is not affiliated with or endorsed by Open Source Matters or the Joomla!® Project.

Santorum
Joomla Extensions