Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding buttons in the dialog's header part?

I want to add two buttons in the dialog's header part along with the 'x' icon, but I can only add the buttons at the bottom of it, even after searching for hours, I didn't get any solution of adding them at the top or changing their position from bottom to top. Please help me out.

$(function(){
   var winsize = ["width=400,height=500"];
   var newwin = function() {
      window.open("http://www.google.com", "New Window", winsize);
      $(this).dialog("close");
   }
   var hide = function() {}
   var btns = {
       buttons: {
         "+": newwin,
         "-": hide
      }
   };
   $( "#dialog" ).dialog(btns);
});
like image 802
Piyush Aggarwal Avatar asked May 21 '26 21:05

Piyush Aggarwal


1 Answers

It's ugly, but maybe a kick in the right direction...

http://jsfiddle.net/AjKFe/48/

//create dialog
$("#dialog2").dialog({
    height: 140,
    modal: true,
    autoOpen: false
});

//add a button
$("<a href='#' style='float:right; margin-right:1em;'></a>").button({icons:{primary: "ui-icon-plus"},text: false}).insertBefore('.ui-dialog-titlebar-close').click(function(e){
   e.preventDefault();
   alert("click");
});
like image 106
Homer Avatar answered May 24 '26 12:05

Homer