简体   繁体   English

如何在jQuery中将UI对话框与UI选项卡结合?

[英]How to combine UI Dialog with UI Tabs in jQuery?

So I'm trying to combine the Dialog with the Tabs UI components form jQuery UI am I'm almost there but I cannot seem to move the dialog close button from the Dialog UI titlebar into the Tabs UI. 因此,我正在尝试将Dialog与Tabs UI组件结合起来,形成jQuery UI的方式已经差不多了,但是我似乎无法将对话框关闭按钮从Dialog UI标题栏中移至Tabs UI中。

I tried to move the existant Dialog UI titlebar close button to the Tabs UI bar but that presented lots of problems and the button moved on mouse hover. 我试图将现有的Dialog UI标题栏关闭按钮移至Tabs UI栏,但这带来了很多问题,并且按钮在鼠标悬停时移动了。 I tried to create buttons with the close icon in the Tabs UI bar but this is proving to be difficult to position the button on the far right side, with the look and feel of a button (with the close icon on it). 我试图在Tabs UI栏中创建带有关闭图标的按钮,但是事实证明,要通过按钮的外观和感觉将按钮放置在最右侧(带有关闭图标)。

The problem is that the Tabs UI bar only accepts <li> because it's a <ul> . 问题是Tabs UI栏仅接受<li>因为它是<ul> If I want to add something else there, I need to enclose it in <li> and that's causing lots of problems or I'm failing to see the easy solution. 如果要在此处添加其他内容,则需要将其括在<li> ,这会引起很多问题,或者我看不到简单的解决方案。

Can anyone help me out? 谁能帮我吗?

Here's my current code: 这是我当前的代码:

<script type="text/javascript">
    $(document).ready(function() {
        $('#dialog-movie-info').dialog({
            draggable: false,
            resizable: false,
            show: 'fade',
            hide: 'fade',
            modal: true,
            height: 370,
            width: 650,
            position: ['center', 35],
            open: function() {
                //$('.ui-dialog-titlebar-close').appendTo('#ui-tab-dialog-close');
                $(this).parent().children('.ui-dialog-titlebar').remove();
                $('#tabs-movie').tabs();
            },
            close: function() {
                $(this).find('#tab-info').children().remove();
                $(this).dialog('destroy');
            }
        });
    }
</script>
<div id="dialog-movie-info" class="ui-helper-hidden">
  <div id="tabs-movie">
    <ul>
      <li><a href="#tab-info"><img src="template/images/icon-block.png" alt="" />Information</a></li>
      <li><a href="#tab-cast"><img src="template/images/icon-block.png" alt="" />Cast List</a></li>
    </ul>
    <div id="tab-info">
      <em>Info tab...</em>
    </div>
    <div id="tab-cast">
      <em>Cast tab...</em>
    </div>
  </div>
</div>

I find a solution that works great for me: 我找到了一个对我有用的解决方案:

Javascript: Javascript:

$(document).ready(function() {
    $('#tabs-movie').tabs();

    $('#dialog-movie-info').dialog({
        closeOnEscape: false,
        draggable: false,
        resizable: false,
        autoOpen: false,
        open: function() {
            $(this).find('.ui-dialog-titlebar-close').blur();
        }
    }).parent().find('.ui-dialog-titlebar-close').prependTo('#tabs-movie').closest('.ui-dialog').children('.ui-dialog-titlebar').remove();
});

HTML: HTML:

<div id="dialog-movie-info">
  <div id="tabs-movie">
    <ul>
      <li><a href="#tab-info"><img src="template/images/icon-block.png" alt="" />Information</a></li>
      <li><a href="#tab-cast"><img src="template/images/icon-block.png" alt="" />Cast List</a></li>
    </ul>
    <div id="tab-info"></div>
    <div id="tab-cast">
      <em>Cast Tab!</em>
    </div>
  </div>
</div>

CSS: CSS:

#tabs-movie {
    border: none;
    padding: 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM