Estoy trabajando para actualizar nuestro sitio web de Bootstrap 3 a Bootstrap 4. Tengo un cuadro de diálogo de JQuery que ya no funciona cuando cambio a Bootstrap 4; el contenido del cuadro de diálogo no se muestra. Los botones en la definición de diálogo de JQuery son, pero nada más. ¡Cualquier idea es apreciada!
Diálogo de Bootstrap 3:
Diálogo de Bootstrap 4:
var themedialog = $("#theme-change-form").dialog({ autoOpen: false, height: 'auto', width: 450, modal: true, buttons: { "Update Theme": updateTheme, Cancel: function() { themedialog.dialog("close"); } }, close: function() { $('.subtheme-button').removeClass('active'); $('.subtheme-button.selected').addClass('active'); } }); //Open dialog when change logo link clicked $('#change-theme').on("click", function() { themedialog.dialog('open'); }); function updateTheme() { console.log('theme udated'); }
<link href="https://code.jquery.com/ui/1.11.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css" /> <link href="https://cdn.usebootstrap.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" /> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js" integrity="sha256-xNjb53/rY+WmG+4L6tTl9m6PpqknWZvRt0rO1SRnJzw=" crossorigin="anonymous"></script> <script src="https://cdn.usebootstrap.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js" type="text/javascript"></script> <div hidden id="theme-change-form"> <div> <h3>Air</h3> <button class='subtheme-button' data-pkSubThemeID='3'>Acid Precipitation</button> </div> <!--more buttons here in the same format as above--> </div> <button id="change-theme">Change Themes</button>
¡Gracias!
Quite el atributo hidden
en el elemento de diálogo. Bootstrap tiene CSS que establece display: none
en elementos con ese atributo, y no parece necesario de todos modos. El inspector de documentos de su navegador es una gran herramienta para ver cosas como esa.
var themedialog = $("#theme-change-form").dialog({ autoOpen: false, height: 'auto', width: 450, modal: true, buttons: { "Update Theme": updateTheme, Cancel: function() { themedialog.dialog("close"); } }, close: function() { $('.subtheme-button').removeClass('active'); $('.subtheme-button.selected').addClass('active'); } }); //Open dialog when change logo link clicked $('#change-theme').on("click", function() { themedialog.dialog('open'); }); function updateTheme() { console.log('theme udated'); }
body { padding: 30px; }
<link href="https://code.jquery.com/ui/1.11.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css" /> <link href="https://cdn.usebootstrap.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" /> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js" integrity="sha256-xNjb53/rY+WmG+4L6tTl9m6PpqknWZvRt0rO1SRnJzw=" crossorigin="anonymous"></script> <script src="https://cdn.usebootstrap.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js" type="text/javascript"></script> <div id="theme-change-form"> <div> <h3>Air</h3> <button class='subtheme-button' data-pkSubThemeID='3'>Acid Precipitation</button> </div> <!--more buttons here in the same format as above--> </div> <button id="change-theme">Change Themes</button>