Ability to trigger the modal declaratively
See original GitHub issueI want to throw in one more idea out there for your consideration. I also use Micromodal.js in my projects and they have this nice little feature that lets you trigger the modal declaratively without any code. It’s explained if you scroll to the third section. Here’s what it could look like with SweetAlert:
<button data-swal-trigger="hello-world-alert">Click me!</button>
<template id='hello-world-alert'>
<swal-title>Hello world!</swal-title>
<swal-html>Here I come...</swal-html>
</template>
I’m not familiar with the SweetAlert basecode so I don’t know how hard this would be. I guess you would need a MutationObserver to bind a click event listenr to any tag with the data-swal-trigger
attribute.
_Originally posted by @pomartel in https://github.com/sweetalert2/sweetalert2/issues/2112#issuecomment-734835853_
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11 (9 by maintainers)
Top Results From Across the Web
How can I trigger a Bootstrap modal programmatically?
I'm using the modal as part of my signup process and there is server side validation involved. If there are problems I want...
Read more >How to Trigger Modal for React Bootstrap | Pluralsight
In this guide, you will learn how to trigger a React Bootstrap Modal programmatically using state.
Read more >UIB: UI Action to initiate Modal Dialog created in... - ServiceNow
Navigate to the Declarative Action that was created as part of the pre-requsities · Update the payload to have the route, size and...
Read more >ion-modal: Ionic Mobile App Custom Modal API Component
A Modal is a dialog that appears on top of the app's content, and must be dismissed by the app before interaction can...
Read more >Modal | Components - BootstrapVue
Modals are streamlined, but flexible dialog prompts powered by JavaScript and CSS. They support a number of use cases from user notification to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Great advice, thank you @zenflow
I’m also planning to add the
attributeName = 'data-swal-trigger'
argument to thebindClickHandler()
method, so users will be able to do this:My vote goes for
data-swal-template
👍