jquery UI dialog: how to initialize without a title bar?

前端 未结 23 1692
春和景丽
春和景丽 2020-11-29 15:03

Is it possible to open a jQuery UI Dialog without a title bar?

相关标签:
23条回答
  • 2020-11-29 16:03

    If you have multiple dialog, you can use this:

    $("#the_dialog").dialog({
            open: function(event, ui) { 
                //hide titlebar.
                $(this).parent().children('.ui-dialog-titlebar').hide();
            }
        });
    
    0 讨论(0)
  • 2020-11-29 16:03

    For me, I still wanted to use the re-sizable corners, just didn't want so see the diagonal lines. I used

    $(".ui-resizable-handle").css("opacity","0");
    

    Just realized I was commenting on the wrong question. Living up to my namesake :(

    0 讨论(0)
  • 2020-11-29 16:03

    You could remove the bar with the close icon with the techinques described above and then add a close icon yourself.

    CSS:

    .CloseButton {
    background: url('../icons/close-button.png');   
    width:15px;
    height:15px;
    border: 0px solid white;
    top:0;
    right:0;
    position:absolute;
    cursor: pointer;
    z-index:999;
    }
    

    HTML:

    var closeDiv = document.createElement("div");
    closeDiv.className = "CloseButton";
    

    //append this div to the div holding your content

    JS:

     $(closeDiv).click(function () {
             $("yourDialogContent").dialog('close');
         });
    
    0 讨论(0)
  • 2020-11-29 16:05

    Try using

    $("#mydialog").closest(".ui-dialog-titlebar").hide();
    

    This will hide all dialogs titles

    $(".ui-dialog-titlebar").hide();
    
    0 讨论(0)
  • 2020-11-29 16:06

    I think that the best solution is to use the option dialogClass.

    An extract from jquery UI docs:

    during init : $('.selector').dialog({ dialogClass: 'noTitleStuff' });

    or if you want after init. :

    $('.selector').dialog('option', 'dialogClass', 'noTitleStuff');
    

    So i created some dialog with option dialogClass='noTitleStuff' and the css like that:

    .noTitleStuff .ui-dialog-titlebar {display:none}
    

    too simple !! but i took 1 day to think why my previous id->class drilling method was not working. In fact when you call .dialog() method the div you transform become a child of another div (the real dialog div) and possibly a 'brother' of the titlebar div, so it's very difficult to try finding the latter starting from former.

    0 讨论(0)
提交回复
热议问题