Z
Z
zerofx2016-12-15 01:47:51
Programming
zerofx, 2016-12-15 01:47:51

How to correctly pass the post ID to the modal window?

Hello everyone, friends, please tell me, there is a block that briefly describes the post, when you click on the link in the description, I would like the full content to open in a modal window.
As I understand it, I need to transfer to the modal window, more precisely, to its markup, or
1) the post ID - substitute it in the loop and display what I need ...
2) transfer the already finished result to the modal window via ajax
which of these options is correct.
And maybe you know an example to see how it is organized.
Thanks to everyone who will respond!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2016-12-15
@zerofx

2nd example is better in my opinion

W
warcevil, 2016-12-15
@warcevil

I do it through fancybox, I think like many others. You just specify a script that returns a ready-made template to the modal window and that's it.

G
Grigory Vasilkov, 2016-12-15
@gzhegow

Display content using fancybox - template there
Or immediately display all modal windows and hide them, and then in div.modal have the parameter data-modalname="" and a script that opens a new window and closes the old one.
Don't forget about mobile devices with small screens, which means that when creating modals from scratch, you shouldn't use position: absolute, left: 50%, top: 50%, since the window sizes will have to be manually calculated according to the screen size. A universal solution - a dark background under the modal window is done as always position: fixed; width: 100% height: 100%; but add overflow-y: auto;
Потом идет div.modals__table (display: table), div.modals__cell (display: table__cell; vertical-align: middle); сами модалки - inline-block и они будут равняться по центру для любого экрана.
Модалкам после этого можно указать width: calc(100% - _двойной_отступ_) и потом каждой конкретной модалке задавать max-width.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question