3

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);
});
4
  • Can you show the code you have so far? Commented Jun 24, 2011 at 17:40
  • Please add this to the original question so it's easier to read and help out. Commented Jun 24, 2011 at 17:43
  • where is dialogOpts being set? Commented Jun 24, 2011 at 18:18
  • There is nothing dialogOpts, I typed it by mistake, I've called the var btns in dialog. Commented Jun 24, 2011 at 18:31

3 Answers 3

3

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");
});
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a ton, this is exactly what I've been looking for, you are really great :)
If it's the answer you're looking for, why not mark it as the answer?
0

I've worked around this by putting regular buttons in the title of my dialog. of course, you have to wire them up manually and such, so it's not an simple solution.

Comments

0

You could also do the following:

    var titlebar = dialog.parents('.ui-dialog').find('.ui-dialog-titlebar');
    $('<button>-</button>')
        .appendTo(titlebar)
        .click(function() {
            // smth here
    });         
    $('<button>+</button>')
        .appendTo(titlebar)
        .click(function() {
            //smth here
    }); 

or use jQuery icons by replacing "-" and "+" by

<span class="ui-icon ui-icon-minusthick">minimize</span>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.