Hi there,
This isnāt fully documented as itās an internal API and subject to change, but there are two functions available to retrieve and set the state. Here are some code examples:
var isModalOpen = window.xToggleGetState( id );
window.xToggleUpdate( id ); // Flips the state.
window.xToggleUpdate( id, true ); // Forces element open
window.xToggleUpdate( id, false ); // Forces element closed
The id
is the value of the data-x-toggleable
attribute. This API could potentially be used for other purposes as long as the attributes match between elements that need to synchronize. The ID value itself just comes from the element ID because we already know thatās unique. If you add a custom class, you can retrieve that value with some jQuery like this:
$('.modal-a').attr('data-x-toggleable');
So you may want to try something like this:
jQuery(function($){
$('a.modal-group-create').on('click',function(){
window.xToggleUpdate( $('.modal-a').attr('data-x-toggleable'), false ); // Close Modal A
window.xToggleUpdate( $('.modal-b').attr('data-x-toggleable'), true ); // Open Modal B
});
});
This works for modals, off canvas, and collapse based elements. We built this out to handle state management so the toggle itself can reflect the open/closed state regardless of how itās triggered. For example, when you click the āxā to close the modal, or click outside the content area, we still need the actual toggle to animate back to the closed position.
Hopefully this helps get you on the right track. Itās unlikely that weāll ever change those functions, but because theyāre internal just remember that weāre not testing them for breaking changes. If you use them youāll just want to test after each update to make sure itās still in good order (as with any customization).