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

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

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

相关标签:
23条回答
  • 2020-11-29 15:51

    Actually there's yet another way to do it, using the dialog widget directly:

    You can get the Dialog Widget thus

    $("#example").dialog(dialogOpts);
    $dlgWidget = $('#example').dialog('widget');
    

    and then do

    $dlgWidget.find(".ui-dialog-titlebar").hide();
    

    to hide the titlebar within that dialog only

    and in a single line of code (I like chaining):

    $('#example').dialog('widget').find(".ui-dialog-titlebar").hide();
    

    No need to add an extra class to the dialog this way, just go at it directly. Workss fine for me.

    0 讨论(0)
  • 2020-11-29 15:55

    I think the cleanest way of doing it would be to create a new myDialog widget, consisting of the dialog widget minus the title bar code. Excising the title bar code looks straightforward.

    https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.dialog.js

    0 讨论(0)
  • 2020-11-29 15:59

    Try this

    $("#ui-dialog-title-divid").parent().hide();
    

    replace divid by corresponding id

    0 讨论(0)
  • 2020-11-29 15:59

    This is How it can be done.

    Go to themes folder--> base--> open jquery.ui.dialog.css

    Find

    Followings

    if you don't want to display titleBar then simply set display:none as i did in the following.

    .ui dialog.ui-dialog .ui-dialog-titlebar 
    {
        padding: .4em 1em;
        position: relative;
            display:none;
    }
    

    Samilarly for title as well.

    .ui-dialog .ui-dialog-title {
        float: left;
        margin: .1em 0;
        white-space: nowrap;
        width: 90%;
        overflow: hidden;
        text-overflow: ellipsis;
        display:none; 
    }
    

    Now comes close button you can also set it none or you can set its

    .ui-dialog .ui-dialog-titlebar-close {
        position: absolute;
        right: .3em;
        top: 50%;
        width: 21px;
        margin: -10px 0 0 0;
        padding: 1px;
        height: 20px;
    
       display:none;
    
    }
    

    I did lots of search but nothing then i got this idea in my mind. However this will effect entire application to don't have close button,title bar for dialog but you can overcome this as well by using jquery and adding and setting css via jquery

    here is syntax for this

    $(".specificclass").css({display:normal})
    
    0 讨论(0)
  • 2020-11-29 16:00

    This worked for me to hide the dialog box title bar:

    $(".ui-dialog-titlebar" ).css("display", "none" );
    
    0 讨论(0)
  • 2020-11-29 16:00

    This worked for me

     open: function(event, ui) {
                $(".ui-dialog-titlebar", $(this).parent())
                  .hide();
    

    Full

    $speedbump.dialog({
      dialogClass: 'speedbump-container',
      autoOpen: false,
      closeOnEscape: false,
      modal: true,
      resizable: false,
      draggable: false,
      create: function () {        
          $speedbump
            .closest('.ui-dialog')
            .attr('id', 'speedbump-container');
      },
      open: function(event, ui) {
        $(".ui-dialog-titlebar", $(this).parent())
          .hide();
    }
    
    0 讨论(0)
提交回复
热议问题