Designing the Buttons of a jQuery UI Dialog

I have been struggling to customize a jQuery UI dialog for quite some time now, and it feels like I'm going in circles. Despite achieving the desired look by manually adding buttons to the dialog as demonstrated in this working example.

However, my goal is to follow the proper method by adding buttons according to the jQuery UI manual. Removing the numerous factory classes automatically added to the buttons, I tried to add a few custom classes instead.

$(this).dialog("widget").find('button').removeClass('ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only').parent().removeAttr('class').parent().removeAttr('class');
...
buttons     : [
{text:'YES, DELETE IT',class:'newButton red',click: function() {alert("Delete Record");$(this).dialog("close");}},
{text:'CANCEL',class:'newButton gray',click: function() {$(this).dialog("close");}}
]

You can view my unsuccessful attempt at the following link: This doesn't quite work.

Initially, the buttons lack the color image until clicked elsewhere on the dialog, causing the image to appear. Additionally, when reopening the dialog, its height increases unexpectedly. While the buttons also seem squished together, that issue may be resolved with further troubleshooting.

Your assistance in identifying the mistakes in my approach would be greatly appreciated!

Answer №1

Let me explain what's happening:

When the page initially loads, the red button is styled with a class of ui-state-focus. However, once you click anywhere on the page, this class is removed, causing the button to display the red background image. Additionally, it seems that the button is inheriting certain styles from the following CSS:

.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
  font-family: Verdana,Arial,sans-serif;
  font-size: 1em;
}

This could be the reason why the text appears larger than expected. Furthermore, it appears that your buttons are not inheriting some specific CSS properties as seen in your original code snippet:

#dialog-deleteListRecord button {
  -moz-border-radius: 5px;
  -khtml-border-radius: 5px;
  -webkit-border-radius: 5px;
  border-radius: 5px;
  cursor: pointer;
  padding; 3px 8px;
  color: white;
  font-size: 12px;
  font-weight: bolder;
  font-family: Arial, Helvetica, sans-serif;
}

I hope this information helps point you in the right direction to resolve the issue at hand.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Comparing attribute selectors to class selectors in the realm of styling

I often come across code that looks like this: <input type="text" class="class1" name="text"> <input type="submit" class="class2" name="submit"> which is then styled as follows: input[type=text] { styles here...} input[type=submit] { sty ...

What is the best way to define the width of text inside a div block?

I'm having trouble adjusting the width of the text in my code to only fill 80% of the body element. I've tried using both the width property and padding, but neither seems to be working for me at the moment. Here's the HTML: <body&g ...

Unable to make CSS footer stay at the bottom of the page following the utilization of V-for to display a list of items in

Footer seems to be misbehaving by not staying at the bottom and instead showing under the items rendered using v-for. This issue is only happening on this page while it is working fine on others. <template> <div> <!-- Item renderin ...

Can you explain how Google highlights the specific search term within the description?

The functionality of my search engine is quite similar to how Google search works. When you search for a word, it gets highlighted in the returned results. https://i.sstatic.net/Y1vc0.png In my search engine, the searched word is enclosed in a span like ...

JQuery enables nested sorting functionality

I need to enable the sortable feature specifically for the charts. Index.cshmtml <div id="sortable" class="col-lg-9"> <div class="col-lg-12 col-md-12 padding hidden" id=@($"chartNumber{Model.Charts[ ...

How can one element be made to rely on the presence of another element?

I'm currently working on my portfolio website and encountering an issue. Whenever I hover over an image of a project, the image expands in size, becomes less transparent, and a description of the project pops up. However, I would like to include a lin ...

Displaying a carousel of cards with a stacking effect using CSS and React

https://i.sstatic.net/254kG.jpgI am looking to design a layout similar to the image provided, where cards are stacked on top of each other with three dots for toggling. Can anyone guide me on how to achieve this visual effect? ...

Tips for keeping two divs aligned horizontally on a webpage

Currently diving into the world of Bootstrap 5, I am facing a challenge with keeping my links and the label "Testing" on the same line. Despite using text-start and text-end classes, they refuse to cooperate. How can I ensure that they both stay aligned ho ...

React's Material-UI AppBar is failing to register click events

I'm experimenting with React, incorporating the AppBar and Drawer components from v0 Material-UI as functional components. I've defined the handleDrawerClick function within the class and passed it as a prop to be used as a click event in the fun ...

Unique custom CSS and meta tag options for enhancing iPad/iPhone user experience

Currently, I am developing a web application that integrates Extjs components, PHP, and MySQL. My main goal is to ensure that my application looks correct on the iPad. Are there any specific CSS rules or meta tags that I should be implementing for optima ...

The HTML width of 100% extends beyond the boundaries of the page

Having limited experience with HTML and CSS, I'm encountering an issue with setting the width to 100%. It seems to exceed the browser borders. Can someone check out the example below? Should I slightly decrease the width percentage, or could there be ...

Ramjet: Unveiling the Magic of Making Elements Appear and Disappear

Currently, I am attempting to implement the code for ramjet from . However, I am facing an issue where element a does not disappear when transitioning into b. Additionally, I am encountering an error message "--Uncaught TypeError: Cannot read property &apo ...

Focusing on the Div element to set the background color

I'm attempting to target the specific div that will allow me to add a background color to the highlighted red area below. I've tried using this code #yui_3_10_1_1_1370470471782_587, but I'm not sure if it's the correct one. If someone ...

Can you explain the purpose of the property named "-webkit-min-logical-width"?

Recently, I encountered a CSS issue where setting the min-width property worked in Firefox but broke in Webkit. After experimenting with the Chrome inspector, I found that using the property -webkit-min-logical-width with a different value than min-width r ...

There is a noticeable absence of top padding

Currently in the process of designing a custom WP theme, I have encountered an issue with styling the header links as seen in the image. Despite my attempts to fill the bluish gradient area with a black background using the .current class, the desired effe ...

"Create a unique visual layout with CSS using a four-grid

When utilizing four div grids and increasing the content size of table 2, it causes table 3 to align with table 4, creating a large gap between tables 1 and 3. Is there a way to adjust the responsive content sizing for tables 1, 3, 5... and 2, 4, 6... in o ...

What could be causing my items to not be aligned horizontally in my Flexbox navbar?

I've been experimenting with the navbar design featured in the Youtube video titled "Animated Responsive Navbar with CSS" by Fireship. My goal is to have the items in my navbar aligned horizontally at the center. Here's a snippet of the HTML stru ...

Moving divs to a separate line in mobile display

I currently have a basic image-thumbnails landing page set up like this: <div style="display: inline-block;"><img style="margin: 3px 3px;" src="..." alt="" width="200" height="200" /></div> <div style="display: inline-block;"><i ...

Ways to arrange two divs side by side and ensure that the content remains within the respective divs

Although I have searched for a similar solution, I haven't found an exact scenario that matches my current issue. Here is the problem: I have a div on the right (with a fixed width), and the entire left side is occupied by another div. While I can pos ...

The input field will be in a read-only state if it contains a value from the database. However, it will be editable if the value

Hello everyone, I am a newcomer to this community and would greatly appreciate your help. I am encountering an issue with the following lines of code: <input type="text" class="form-control" id="fines" name="fines&quo ...