-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include complex HTML in dialog #40
Comments
You can place any HTML you want inside a dialog. You can do this by setting <html>
<head>
<style>.templates { display: none }</style>
<body>
<header><!--- .. --></header>
<main><!--- .. --></main>
<div class="templates">
<sidebar id="sidebarTemplate"><!--- .. --></sidebar>
</div>
</body> You could either do this: vex.open({
content: $(sidebarTemplate).clone()
}); Or this: var $vexContent = vex.open();
$vexContent.append($(sidebarTemplate).clone()); Of course, you'll additionally want to set the |
Ah, tricky. I’ve been struggling with passing html as strings but never thought to do that. |
No problem. There is more info in the Advanced page of the docs as well. |
Cloning HTML could produce duplicated IDs, which is bad and could introduce issues with other JS libraries or CSS. In my case, to warkaround this I wrapped up my templates into $(document).on('click', '[data-vex-toggle="modal"]', function (e) {
e.preventDefault();
var $trigger = $(this);
var $template = $('script[type="text/html"]#' + $trigger.data('template'));
if (!$template.length) {
return;
}
vex.open({
content: $template.html(),
className: 'vex-theme-default'
});
}); |
I need to create a fairly complex modal sidebar for something like settings. I'd like to have is slide out from the left and remain in place attached to the left side of the viewport/window. The user will fiddle with settings and dismiss at some point.
I can see how to do most of this but wonder about how to put the fairly complex HTML into the dialog.
The text was updated successfully, but these errors were encountered: