Button classes not added in jQuery UI Bootstrap Dialog
Asked Answered
C

3

8

I've added UI Bootstrap theme to my application and most of it seems to work very well, but I can't seem to get my UI dialog buttons to render correctly like the demo. It seems that jQuery UI is not adding the classes to the buttons so that the buttons will be styled.

Using Chrome developer the buttons should render as:

<button type="button" 
   class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" 
   role="button" 
   aria-disabled="false">
      <span class="ui-button-text">Ok</span>
</button>

But when I create my dialog:

$('#dialog').dialog({
   title: 'My Text',
   close: function (event, ui) {
      myfunction();
   },   
   bgiframe: false,
   width: 860,
   height: 500,
   resizable: true,
   modal: true,
   buttons: {
      Cancel: function () {
         $(this).dialog("close");
      } 
   }
});

The ui dialog buttons render as so:

<button type="button">Cancel</button>

No classes are being added and I can't find anything that tells me IF I need to execute other methods or what the deal is.

Thanks.

-V

Edit: sorry I forgot to reference the versions I'm using:

Bootstrap: 2.2.2 jQuery: 1.8.3 jQuery UI: 1.9.2

Computation answered 10/12, 2012 at 21:48 Comment(4)
I'm not sure if it's possible. Do you need to use the JQuery dialog? Check this link: forums.asp.net/t/1761495.aspx/…Heptad
You might find this useful as well: addyosmani.github.com/jquery-ui-bootstrapHeptad
Yes this is what I'm using. It's noted in the title and the first line of the question :-)Computation
I'm sorry for my mistake. Can you put all the css and js files that you have added? I have added the same files as in the code samples and it is working: css/custom-theme/jquery-ui-1.8.16.custom.css, bootstrap/bootstrap.css, js/jquery-1.6.2.min.js, js/jquery-ui-1.8.16.custom.min.jsHeptad
C
19

Ok I resolved this myself.

It was simply the order of my javascript files.

Be sure to load bootstrap.js before you load jquery.ui

Once I did this all the button classes applied natively by ui appeared correctly.

Thanks to everyone to contributed.

-V

Computation answered 11/12, 2012 at 2:2 Comment(4)
thank's great work but bootstrap tooltip change to jquery ui tooltipBistort
yeah this is from 2012Computation
three years later you saved my morning angerKindhearted
Glad it helped you out :)Computation
C
13

This is because bootstrap's button() function conflicts with Jquery UI's button() function. See this bug for more information: https://github.com/twitter/bootstrap/issues/6094

If you want to load bootstrap.js after jqueryui, you can use this to move bootstrap's button() function out of the way:

var btn = $.fn.button.noConflict(); // reverts $.fn.button to jqueryui btn
$.fn.btn = btn; // assigns bootstrap button functionality to $.fn.btn

Alternatively, you can use bootstrap modals instead of jqueryui dialogs.

Chile answered 20/2, 2013 at 3:56 Comment(1)
I was so confused as to why my jQuery UI buttons looked different for a while... thanks for this! I only need this temporarily until I can remove jQuery UI dependency in my application and fully switch to bootstrap!Barbusse
N
0

You might need to add this to your js/html file $('button').button(); so that every button should be rendered according to your theme.

Nam answered 10/12, 2012 at 22:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.