Open hoangemini opened 4 years ago
I'm looking for similar functionality. Did you figure it out?
I'm looking for similar functionality. Did you figure it out?
I tried to fix the source but it failed! I had to trigger the submit button to open the modal, which was silly
Have you tried
$('.inline').modaal({
content_source: '#inline'
start_open: true
});
as per the docs?
See: https://github.com/humaan/Modaal#32-programatically-open-a-modaal
@pzi Yes, but I want to open the modal based on actions not when the website first loads. Something like they complete a form and then show up the modal if the form submits, as an example.
CodePen example of triggering the form on form submit: https://codepen.io/pzi/pen/MWKXgxg
HTML
<form>
<label>
Foo
<input />
</label>
<button>Submit</button>
</form>
<div id="inline-content" class="trigger">...</div>
CSS
#inline-content {
display: none;
}
JS
// init modaal
$(".trigger").modaal({ content_source: "#inline-content" });
$("form").on("submit", (event) => {
event.preventDefault();
// open modaal on submit
$(".trigger").modaal("open");
});
Disclaimer: haven't used Modaal that much, so unsure if the "trigger" being on the same as the modaal content is legit, but it seems to work. Can always chuck the trigger class on another element if it's an issue.
I want to use JQuery to open it but don't need any other buttons to open it. Ex:
But not
It is stupid to have
<button class="inline">Show</button>