views:

2062

answers:

2

How can I position buttons from jQuery UI separately from each other. Buttons are aligned in same direction. I would like one button to be aligned to left while the other to the right. Is it possible?

+5  A: 

OK, looking at this through Firebug...

The Dialog control create a div with a class called ui-dialog-buttonpane, so you can search for that.

If you are dealing with multiple buttons, you will probably want :first and :last attributes.

So, $(".ui-dialog-buttonpane button:first) should get you the first button. and $(".ui-dialog-buttonpane button:last) should get you the last button.

From there you can modify the css/style to put each button on the right and left (modify the float values).

Anyway, that is how I would approach it right now.

Chris Brandsma
Exactly! So simple...
turezky
This doesn't work if you have multiple dialogs.
Brian C. Lane
Then expand the selectors a bit. $("div.dialog < .ui-dialog-buttonpane button:last) and $(""div.dialog < .ui-dialog-buttonpane button:first) should work. The div.dialog should be the owner of the dialog in the first place.
Chris Brandsma
A: 

you could also add class to your dialog (http://docs.jquery.com/UI/Dialog#option-dialogClass) to localize your styling.

pashcan