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).