Dropdown appears in sweetalert 2 when initializing materialize dropdowns
See original GitHub issueCurrent behavior
A drop down menu appears in sweet alert 2 alerts when materialize is used and drop downs initialized. This occurs even if no input is specified for the alert.
Expected behavior
No dropdown to appear if it is not required as an input
Live demo
https://jsbin.com/peqatexaze/edit?html,js,output
You will notice the dropdown appear. Remove:
$(document).ready(function(){
$('select').formSelect();
});
and the dropdown will no longer appear.
An issue has been opened with the creator here but he is unfamiliar with materialize so I thought an issue here may help solve this.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
Dropdown - Materialize
The DOM element the plugin was initialized with. options, Object, The options the instance was initialized with. id, String, ID of the dropdown...
Read more >missing select options with Sweet Alert - Stack Overflow
Your code works just fine with included SweetAlert2 library: Swal.fire({ title: 'Select Outage Tier', input: 'select', inputOptions: { '1': ...
Read more >Common problems - The jQuery replacement for select boxes
This issue occurs because Bootstrap modals tend to steal focus from other elements outside of the modal. Since by default, Select2 attaches the...
Read more >Dogfalo/materialize - Gitter
Hey guys, I would like to report a bug while using the custom "<select>" element with ... init.js:22 j @ jquery-3.1.0.min.js:2 k @...
Read more >Form Select2 - Material Design Admin Template - Pixinvent
Materialize is a Material Design Admin Template,It's modern, ... Select2 gives you a customizable select box with support for searching, tagging, ...
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 FreeTop 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
Top GitHub Comments
The way Materialize works is, a
<select>
is replaced with a custom component (the select is actually still there but hidden) containing a<input>
plus a dropdown. As seen here: https://github.com/Dogfalo/materialize/blob/v1-dev/js/select.js#L216What you could do instead is restrict which
<select>
s gets the materialize treatment (adding a specific class, for example).If you just wanna ignore this specific case, this should work:
Which will match any select but the one created by
swal({...})
.Edit:
Updated your demo:
https://jsbin.com/pakiqad/1/edit?html,css,js,output
I had the same problem described by @cheesemarathon, and this workaround works fine. Thanks for your explanation.