There is some kind of dialog on jQuery UI:

$("#dialog").dialog({ dialogClass: 'test', autoOpen: false }); $("#open").click(function(){ $("#dialog").dialog("open"); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" /> <button id="open">Open</button> <div id="dialog"> Π”ΠΈΠ°Π»ΠΎΠ³ </div> 

How can I add a "maximize" button on the titlebar (near the cross)?
Well, or just how to add a button?

    1 answer 1

    In theory, the buttons can only be added to the lower bar. But without crutches and life is simple!

    http://jsfiddle.net/9rwfZ/1/

     $("#dialog").dialog({ dialogClass: 'test', autoOpen: false, // вызываСмая функция ΠΏΡ€ΠΈ ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΈΠΈ ΠΎΠΊΠ½Π° open: function(event, ui) { // создаСм ΠΊΠ½ΠΎΠΏΠΊΡƒ var $buttonMaximize = $('<a href="#"><span class="ui-icon ui-icon-closethick">maximize</span></a>') .addClass('ui-dialog-titlebar-maximize') .addClass('ui-corner-all'); //Π·Π°ΠΏΠΎΠΌΠΈΠ½Π°Π΅ΠΌ контСкст ΠΎΠΊΠ½Π° var $that = $(this); // добавляСм Π½Π°ΡˆΡƒ ΠΊΠ½ΠΎΠΏΠΊΡƒ Π΄ΠΎ ΠΊΠ½ΠΎΠΏΠΊΠΈ "Π·Π°ΠΊΡ€Ρ‹Ρ‚ΡŒ" $that.parent().children().children('.ui-dialog-titlebar-close').before($buttonMaximize); // вСшаСм событиС Π½Π° Π½Π°ΡˆΡƒ ΠΊΠ½ΠΎΠΏΠΊΡƒ $buttonMaximize.on('click', function() { $that.dialog({ width: $(window).width()-20, height: $(window).height()-20, position: [0,0] }); }); } }); 
    • one
      Thank you :) by the way, I also messed around a bit, and it turned out something like this: jsfiddle.net/9rwfZ/2 added this piece: var adda = jQuery ('<a href = "#" target = "_ blanck" id = "maximized "> ') .addClass (' ui-dialog-titlebar-close ui-corner-all ') .attr (' role ',' button '). css (' right ',' 1.7em '). mouseover (function ( ) {jQuery (this) .addClass ('ui-state-hover');}) .mouseout (function () {jQuery (this) .removeClass ('ui-state-hover')}). append ("<span class = 'ui-icon ui-icon-newwin'> </ span> "); jQuery (". test"). children (". ui-dialog-titlebar"). append (adda); - IVsevolod
    • one
      @IVsevolod note, with dynamic elements will not work. It is better to think over the architecture a little) - lampa
    • @lampa, mm, already built into his subtask, works fine. Satisfied :) - IVsevolod