Magnific-Popup icon indicating copy to clipboard operation
Magnific-Popup copied to clipboard

Prepend to option?

Open AdamWebDev opened this issue 11 years ago • 6 comments

I'm using this plugin on an ASP.net project, and because the modal box prepends to document.body, which is outside of the form element (which all .net controls must reside in), I lose the ability to have functional controls inside the modal box.

I resolved the issue in my project by replacing changing this line:

n.bgOverlay.add(n.wrap).prependTo($('#form1'))

Just wondering if there's an option you could throw in that you could place a class or ID to, and have the modal prepend to that element instead of the default document.body?

AdamWebDev avatar Jul 25 '13 18:07 AdamWebDev

Sorry for late response, be careful with this, as if your form doesn't fill 100% width and height of a window, you might get into troubles on mobile. To force same layout on desktop and mobile set fixedContentPos and bgpos to true or false http://dimsemenov.com/plugins/magnific-popup/documentation.html#fixedcontentpos

I guess you were changing this line: https://github.com/dimsemenov/Magnific-Popup/blob/master/src/js/core.js#L380

I don't have much experience with ASP.net, so if this works for you, you may submit a commit.

dimsemenov avatar Aug 07 '13 05:08 dimsemenov

I think is good to have this option. I think it won't break any core issues (but developer must know what he/she is doing), developer only use css to style what they need to fit their requirement. This will also solve this issue related: https://github.com/dimsemenov/Magnific-Popup/issues/166

In my case, I have a SPA site where section by section scrolling. Client preferred to have that video popup inside that section instead of modal pop up overlay the whole page.

Is good to have this option something like:

// Append to any ID or class element container
$('.some-button').magnificPopup({
  appendTo: $('#myVideoContainer')
});

// Append to closest parent element container
$('.some-button').magnificPopup({
  appendTo: $(this).closest('.section-video-component')
});

claudchan avatar Aug 08 '17 02:08 claudchan

This option would be a great addition to this magnificent plugin. Here is one popup plugin that have option to change append location (look for appendLocation option) http://github.hubspot.com/vex/api/advanced/

dariodev avatar Aug 31 '18 12:08 dariodev

It seems that this option already exists #304 :) Why this is not closed as resolved?

dariodev avatar Aug 31 '18 12:08 dariodev

Please add option like prepend to closest / parent div:

// Prepend to closest parent element container
$('.some-button').magnificPopup({
  prependTo: $(this).closest('.section-video-component')
});

claudchan avatar Sep 04 '18 09:09 claudchan

The option to prepend to closest parent will be very helpful. Hope this is addressed in the future.

vsaini603dev avatar Nov 08 '20 11:11 vsaini603dev