We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8901
    • 18 Posts
    Hi everyone!
    I tried to created a popup window on a page on modx, but it doesnt work. I works on a static, regular html page, but on Modx I guess the ’mecanic’ is different.
    I was trying to use this: http://www.queness.com/post/77/simple-jquery-modal-window-tutorial
    made several tests and nothing happened.

    If anyone can help me... or perhaps there is a Modx Addon for it...

    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Works fine for me.

      However, I did need to change the configuration for QuickManager, as it by default wants to load JQuery in "no conflict" mode, and when it does that the $ doesn’t work. For this test, I just told QM to not load JQuery at all, and loaded it myself in the template head. Here’s my testing template
      <!DOCTYPE html>
      <html lang="en">
      <head>
      <meta charset="[(modx_charset)]">
      <title>Modal Windows</title>
      <base href="[(site_url)]"></base>
      
      <style type="text/css">
      
      /* Z-index of #mask must lower than #boxes .window */
      #mask {
        position:absolute;
        z-index:9000;
        background-color:#000;
        display:none;
      }
        
      #boxes .window {
        position:absolute;
        width:440px;
        height:200px;
        display:none;
        z-index:9999;
        padding:20px;
      }
      
      
      /* Customize your modal window here, you can add background image too */
      #boxes #dialog {
        width:375px; 
        height:203px;
      }
      </style>
      
      <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
      </head>
      <body>
      [*content*]
      </body>
      </head>

      And the content of the resource (copy/pasted direct from the page linked above):
      <!-- #dialog is the id of a DIV defined in the code below -->
      <a href="#dialog" name="modal">Simple Modal Window</a>
      
      <div id="boxes">
      
      	
      	<!-- #customize your modal window here -->
      
      	<div id="dialog" class="window">
      		<b>Testing of Modal Window</b> | 
      		
      		<!-- close button is defined as close class -->
      		<a href="#" class="close">Close it</a>
      
      	</div>
      
      	
      	<!-- Do not remove div#mask, because you'll need it to fill the whole screen -->	
       	<div id="mask"></div>
      </div>
      
      <script type="text/javascript">
      
      $(document).ready(function() {	
      
      	//select all the a tag with name equal to modal
      	$('a[name=modal]').click(function(e) {
      		//Cancel the link behavior
      		e.preventDefault();
      		//Get the A tag
      		var id = $(this).attr('href');
      	
      		//Get the screen height and width
      		var maskHeight = $(document).height();
      		var maskWidth = $(window).width();
      	
      		//Set height and width to mask to fill up the whole screen
      		$('#mask').css({'width':maskWidth,'height':maskHeight});
      		
      		//transition effect		
      		$('#mask').fadeIn(1000);	
      		$('#mask').fadeTo("slow",0.8);	
      	
      		//Get the window height and width
      		var winH = $(window).height();
      		var winW = $(window).width();
                    
      		//Set the popup window to center
      		$(id).css('top',  winH/2-$(id).height()/2);
      		$(id).css('left', winW/2-$(id).width()/2);
      	
      		//transition effect
      		$(id).fadeIn(2000); 
      	
      	});
      	
      	//if close button is clicked
      	$('.window .close').click(function (e) {
      		//Cancel the link behavior
      		e.preventDefault();
      		$('#mask, .window').hide();
      	});		
      	
      	//if mask is clicked
      	$('#mask').click(function () {
      		$(this).hide();
      		$('.window').hide();
      	});			
      	
      });
      
      </script>
      
      
      
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 8901
        • 18 Posts
        Hey Sottwell.
        Thanks for your response. Following your guide, I was able to do it my self and worked just fine!!!
          • 33238
          • 388 Posts
          I never try this before but i have this in my bookmarks to try some day.

          may be work for you!!!

          http://modxcms.com/extras/package/348

          good look!!! grin
            --
            ysanmiguel.com
            • 32519
            • 94 Posts
            Quote from: Ysanmiguel at May 19, 2010, 01:53 AM

            I never try this before but i have this in my bookmarks to try some day.

            may be work for you!!!

            http://modxcms.com/extras/package/348

            good look!!! grin

            It doesn’t mean much, but I couldn’t get it to work.
              <a href="http://www.themovietimeline.net">The Movie Timeline</a> | <a href="http://www.antstuff.net">The Antfarm Site</a>
              • 8901
              • 18 Posts
              Quote from: jonnybravo at May 30, 2010, 07:42 AM

              It doesn’t mean much, but I couldn’t get it to work.

              It may be because it hasnt been updated for like tree years...