Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why magnific popup ajax box closes if clicked on content

Please Please Please help me.. I have been trying to get the magnific popup ajax box to show login form. It seems that form appears but as soon as I click anywhere in form or ajax body, it disappears. below is the code

 $(document).ready(function() {
 $('.ajax-popup-link').magnificPopup({
 type: 'ajax',
 alignTop: false,
 closeOnContentClick: false,
 overflowY: 'scroll'
 });
 });

<a class=".ajax-popup-link" href="result.php">try me</a><br>

Below is the php that I look to load in ajax box. This is not the complete one

 Email:<div class="field_container">Password:</label>
    <input type='password' name='cust_password' id='password'  maxlength="12" style="width: 250px; height: 30px"; /></div>

   <input type='submit' name='Submit' value='Login' />
like image 451
user2671781 Avatar asked Aug 13 '13 17:08

user2671781


People also ask

What is magnific popup?

Magnific Popup is a fast, light, mobile-friendly and responsive lightbox and modal dialog jQuery plugin. It can be used to open inline HTML, ajax loaded content, image, form, iframe (YouTube video, Vimeo, Google Maps), and photo gallery. It has added animation effects using CSS3 transitions.

What is jQuery Magnific popup min JS?

Magnific Popup is a responsive lightbox & dialog script with focus on performance and providing best experience for user with any device. (for jQuery or Zepto.js).


1 Answers

This is the old thread but for all the future readers: to fix this, there has to be only one root element in the html that comes out from the ajax call:

As per documentation:

http://dimsemenov.com/plugins/magnific-popup/documentation.html#ajax_type

So in your ajax call you should return something like this:

<div>    
    ...your html content 
</div>

and your popup will no longer close itself on content click.

like image 109
Davor Zlotrg Avatar answered Oct 12 '22 12:10

Davor Zlotrg