UIKit for Oxygen Modals

le 26/10/2021
JAG

This members-only tutorial provides the steps to apply UIKit for Oxygen’s Modal components so they work better especially when there is overflow compared to the earlier shared fix.
Live Demo (scroll down until you see the Open Modal button)
Step 1
Load UIKit in your WordPress site by following Step 1 of this tutorial.
Step 2
Let’s add markup (data attributes, classes) and insert the close button as needed by UIKit using some custom jQuery. The code is set to handle multiple modals and need not be edited after it has been added.

In your plugin’s data-attributes.js add the following between the opening
(function ($) {
and closing
})(jQuery);
// Add uk-toggle data attribute to the modal triggers.
$('.uk-toggle').attr('uk-toggle', '');

// Add unique ID to each .oxy-modal-backdrop based on the ID of .ct-modal inside it.
$('.ct-modal').each(function () {
$id = $(this).attr('id');
$(this).parent().attr('id',$id+'-container');
});

// Add uk-modal attribute to modal containers.
$('.oxy-modal-backdrop').attr('uk-modal', '');

// Add uk-modal-dialog class to modals.
$('.ct-modal').addClass('uk-modal-dialog');

// Add close button inside modals.
$('.ct-modal').prepend('');

// for vertical scrollbar inside the modal body.
$('.uk-modal-body').attr('uk-overflow-auto', '');
Step 3
a) In the Oxygen editor, add a link or a button that should open your modal.
Give it a class of uk-toggle.
Optional: In my demo site, I’ve also added these classes: uk-button, uk-button-default.
b) Select the Inner Content element in the Structure Panel and add a Modal component.
Copy the ID of the Modal. Ex.: modal-59-56
Select the link/button from the earlier step and set its URL to whatever is the ID of the Modal followed by -container.
Ex.: modal-59-56-container
Back to the Modal, do not change or set any of the properties in the Primary section like Trigger, Content Styles, Modal Styles and Closing.
Advanced > Size & Spacing > Width: 600px.
i) This is an optional step.
With the Modal selected in the Structure Panel, add a Div for the modal header.
Give it a class of uk-modal-header.
Add a h2 Heading inside and assign it a class of uk-modal-title.
ii) With the Modal selected in the Structure Panel, add a Div for the modal body.
Assign it a class of uk-modal-body.
Place your main modal content inside.
In my demo site, I added a Shortcode element to show a Gravity Forms Form having this shortcode.
iii) This is an optional step.
With the Modal selected in the Structure Panel, add a Code Block for the modal footer.
Give it a class of uk-modal-footer.
In my demo site, I also gave it a class of uk-text-right so the contents of this Code Block div are aligned to the right.
PHP & HTML:

Reference:
https://getuikit.com/docs/modal

Nos experts se tiennent à votre disposition
pour répondre à vos questions et vous conseiller
dans votre projet digital.

Vous souhaitez développer une application ?

Envie d’échanger avec l’un de nos experts ? Besoin d’en savoir plus ?
En savoir plus

Recevez notre newsletter

La protection des données nous tient à cœur. JAG utilise les informations que vous fournissez afin de vous proposer des informations et du contenu pertinent sur nos produits et services. Vous pouvez vous désinscrire de ce type de communications à tout moment. Pour plus d'informations, consultez notre politique de confidentialité
© 2022 JAG Consulting, sas. Tous droits réservés.
© 2022 JAG Consulting, sas. Tous droits réservés.
4.8
Lire les 51 avis
google
Brieuc Pauly
08/09/2022

Créative, dynamique et très professionnelle, c'est à mon sens les piliers qui soutiennent cette équipe talentueuse ! Une agence à taille humaine qui privilégie la qualité et le résultat. Alors si vous souhaitez le meilleur pour votre communication adressez vous les yeux fermés à ces passionnés, plus que compétents ! (Translated by Google) Creative, dynamic and very professional, these are in my opinion the pillars that support this talented team! A human-sized agency that favors quality and results. So if you want the best for your communication, turn your eyes closed to these enthusiasts, who are more than competent!

google
Amaury Tardier
08/09/2022

Merci à Julien et son équipe, plus que satisfait par le travail fourni ! Je recommande vivement ! (Translated by Google) Thanks to Julien and his team, more than satisfied with the work provided! I highly recommend !

Ravi de travailler avec l'équipe JAG pour la gestion de mon site de e-Commerce. Equipe réactive et toujours pleine de bonnes idées pour améliorer les performances du site (Translated by Google) Glad to work with the JAG team for the management of my e-Commerce site. Responsive team always full of good ideas to improve the performance of the site

Merci à Julien pour son accompagnement dans mon projet, je recommande à 200% c est le Top (Translated by Google) Thanks to Julien for his support in my project, I recommend 200% it is the top

Excellente agence. Equipe est très pro, à l'écoute et de bon conseils. (Translated by Google) Excellent agency. The team is very professional, attentive and gives good advice.

Temps de réponse hors pair quand il y a eu un pb sur mon site, je vous recommande chaleureusement Julien :-) (Translated by Google) Unparalleled response time when there was a problem on my site, I warmly recommend Julien :-)

Charger plus
listarrow-right
Julien

Julien

Votre conseiller

I will be back soon

Une question ?

Julien
Bonjour ! Je suis Julien.
Comment puis-je vous aider?
Démarrer la conversation:
chat Live Chat