jQuery UI Dialog - missing close icon

前端 未结 17 2081
礼貌的吻别
礼貌的吻别 2020-11-28 19:15

I\'m using a custom jQuery 1.10.3 theme. I downloaded every straight from the theme roller and I have intentionally not changed anything.

I created a dialog box and I

相关标签:
17条回答
  • 2020-11-28 19:23

    I had the same exact issue, Maybe you already chececked this but got it solved just by placing the "images" folder in the same location as the jquery-ui.css

    0 讨论(0)
  • 2020-11-28 19:24

    If you are calling the dialog() inside the js function, you can use the below bootstrap button conflict codes

     <div class="row">
       <div class="col-md-12">
           <input type="button" onclick="ShowDialog()"  value="Open Dialog" id="btnDialog"/>
       </div>
    </div>
    
    <div style="display:none;" id="divMessage">
        <table class="table table-bordered">
            <tr>
                <th>Firstname</th>
                <th>Lastname</th>
                <th>Age</th>
            </tr>
            <tr>
                <td>Giri</td>
                <td>Prasad</td>
                <td>25</td>
            </tr>
            <tr>
                <td>Bala</td>
                <td>Kumar</td>
                <td>24</td>
            </tr>
        </table> 
    </div>
    
    
    
    <script type="text/javascript">
        function ShowDialog()
        {
            if (typeof $.fn.bootstrapBtn =='undefined') {
                $.fn.bootstrapBtn = $.fn.button.noConflict();
            }
    
            $('#divMessage').dialog({
                title:'Employee Info',
                modal:true
            });
        }
        </script>
    
    0 讨论(0)
  • 2020-11-28 19:30
      just add in css
     .ui-icon-closethick{
     margin-top: -8px!important;
    margin-left: -8px!important;
    

    }

    0 讨论(0)
  • 2020-11-28 19:33

    This appears to be a bug in the way jQuery ships. You can fix it manually with some dom manipulation on the Dialog Open event:

    $("#selector").dialog({
        open: function() {
            $(this).closest(".ui-dialog")
            .find(".ui-dialog-titlebar-close")
            .removeClass("ui-dialog-titlebar-close")
            .html("<span class='ui-button-icon-primary ui-icon ui-icon-closethick'></span>");
        }
    });
    
    0 讨论(0)
  • 2020-11-28 19:36

    This is a comment on the top answer, but I felt it was worth its own answer because it helped me answer the problem.

    If you want to keep Bootstrap declared after JQuery UI (I did because I wanted to use the Bootstrap tooltip), declaring the following (I declared it after $(document).ready) will allow the button to appear again (answer from https://stackoverflow.com/a/23428433/4660870)

    var bootstrapButton = $.fn.button.noConflict() // return $.fn.button to previously assigned value
    $.fn.bootstrapBtn = bootstrapButton            // give $().bootstrapBtn the Bootstrap functionality
    
    0 讨论(0)
  • 2020-11-28 19:36

    I found three fixes:

    1. You can just load bootsrap first. And them load jquery-ui. But it is not good idea. Because you will see errors in console.
    2. This:

      var bootstrapButton = $.fn.button.noConflict();
      $.fn.bootstrapBtn = bootstrapButton;
      

      helps. But other buttons look terrible. And now we don't have bootstrap buttons.

    3. I just want to use bootsrap styles and also I want to have close button with an icon. I've done following:

      How close button looks after fix

      .ui-dialog-titlebar-close {
          padding:0 !important;
      }
      
      .ui-dialog-titlebar-close:after {
          content: '';
          width: 20px;
          height: 20px;
          display: inline-block;
          /* Change path to image*/
          background-image: url(themes/base/images/ui-icons_777777_256x240.png);
          background-position: -96px -128px;
          background-repeat: no-repeat;
      }
      
    0 讨论(0)
提交回复
热议问题