1

I am using the JQuery UI dialog:

$("#filter").dialog({ autoOpen: false, resizable: false, draggable:false }); 

The close button in their example has:

<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" role="button" aria-disabled="false" title="close"> <span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span> <span class="ui-button-text">close</span></button> 

Mine has:

<button class="ui-dialog-titlebar-close"></button> 

Why does my button not have those styles. I have included the theme and I see the theme for everything else...

Thanks

5
  • Is that button created by the dialog? Or are you manually putting that button in there? Commented Mar 5, 2013 at 21:05
  • It is created by the dialog Commented Mar 5, 2013 at 21:08
  • Do you have any other scripts that might modify the dialog's DOM? The elements are as expected in this minimal example. Commented Mar 5, 2013 at 21:17
  • Nope, nothing special... this really should work... Commented Mar 5, 2013 at 21:25
  • I can confirm that the buttons are generated badly when bootstrap.js (2.3.2) is loaded. If bootstrap.js is not loaded the buttons are generated fine (using jQuery 1.10.2 and jQuery-UI 1.10.3). Commented Aug 20, 2013 at 12:39

3 Answers 3

1

This problem can be caused by the Use of the jQuery UI js with the Twitter Bootsrap js

Sign up to request clarification or add additional context in comments.

Comments

0

The styles will only apply if .ui-dialog-titlebar-close is wrapped inside an element with class .ui-dialog.

I would suggest you to just look at the styles that you like and create a new style declaration for the button.

Comments

-2

Organize file structure

In this screenshot of my file structure above, I downloaded the theme and the UI creation module, jQueryUI. By default, it comes with a predefined theme and style.

Download the template here

Here is a screenshot of where the themes are.

Configure paths for your project

The page that is using jquery example: index.html, in the header add

  • ./js/jquery-ui-themes/themeS/black-tie/jquery-ui.css
  • ./js/jquery-ui-themes/themeS/black-tie/jquery-ui.min.css
  • ./js/jqueryui/jquery-ui.js

Remember to add jQuery from an external source or download the latest version. It's important to configure the events.

To fix the issue with the close icon, you can use this creation method

create: function(event, ui) { // Customize close button $(this).parent().find('.ui-dialog-titlebar-close') .html('<span class="ui-icon ui-icon-closethick"></span>') .addClass('ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only') .attr({ title: "Close", role: "button" }); }, 

Example:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Theme Switcher Modal Example</title> <!-- jQuery UI Theme - Único link que será alterado --> <link id="jquery-ui-theme" rel="stylesheet" href="https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css"> <!-- jQuery and jQuery UI --> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://code.jquery.com/ui/1.13.1/jquery-ui.min.js"></script> <style> body { padding: 20px; font-family: Arial, sans-serif; } .ui-dialog { font-size: 14px; } .theme-selector { margin-bottom: 20px; } .demo-content { padding: 15px; background: #f9f9f9; border-radius: 4px; } </style> </head> <body> <!-- Open Modal Button --> <button id="openModal">Open Configuration</button> <!-- Configuration Modal --> <div id="configModal" title="Theme Configuration"> <div class="theme-selector"> <label for="themeSwitcher">Select Theme:</label> <select id="themeSwitcher"> <option value="base">Base Theme (Default)</option> <option value="smoothness">Smoothness Theme</option> <option value="le-frog">Le Frog Theme</option> </select> </div> <div class="demo-content"> <h2>Theme Preview</h2> <p>This is a demonstration of jQuery UI theme switching.</p> </div> </div> <script> $(function() { // Mapeamento de temas para seus URLs const themeUrls = { 'base': 'https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css', 'smoothness': 'https://code.jquery.com/ui/1.13.1/themes/smoothness/jquery-ui.css', 'le-frog': 'https://code.jquery.com/ui/1.13.1/themes/le-frog/jquery-ui.css' }; // Initialize Dialog $("#configModal").dialog({ autoOpen: false, modal: true, width: 400, resizable: false, create: function(event, ui) { // Customize close button $(this).parent().find('.ui-dialog-titlebar-close') .html('<span class="ui-icon ui-icon-closethick"></span>') .addClass('ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only') .attr({ title: "Close", role: "button" }); }, buttons: { "Save": { text: "Save Changes", class: 'ui-button ui-widget ui-state-default ui-corner-all', click: function() { alert("Settings saved!"); $(this).dialog("close"); } }, "Cancel": { text: "Cancel", class: 'ui-button ui-widget ui-state-default ui-corner-all', click: function() { $(this).dialog("close"); } } } }); // Open Modal Handler $("#openModal").click(function() { $("#configModal").dialog("open"); }); // Theme Switcher Logic - Simplificado $('#themeSwitcher').change(function() { const selectedTheme = $(this).val(); // Atualiza o href do link para o tema selecionado $('#jquery-ui-theme').attr('href', themeUrls[selectedTheme]); // Force UI refresh $('.ui-widget').each(function() { $(this).removeClass('ui-widget').addClass('ui-widget'); }); }); }); </script> </body> </html>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.