如何在jQuery中将UI对话框与UI选项卡结合? [英] How to combine UI Dialog with UI Tabs in jQuery?

查看:55
本文介绍了如何在jQuery中将UI对话框与UI选项卡结合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我试图将Dialog与Tabs UI组件结合起来,形成jQuery UI的状态已经差不多了,但是我似乎无法将对话框关闭按钮从Dialog UI标题栏中移到Tabs UI中.

我试图将现有的Dialog UI标题栏关闭按钮移动到Tabs UI栏,但这带来了很多问题,并且按钮在鼠标悬停时移动了.我试图在Tabs UI栏中创建带有关闭图标的按钮,但是事实证明,将按钮的外观和感觉(带有关闭图标)定位在最右侧是非常困难的.

问题在于选项卡UI栏仅接受<li>,因为它是<ul>.如果要在其中添加其他内容,则需要将其包含在<li>中,这会引起很多问题,或者我看不到简单的解决方案.

有人可以帮我吗?

这是我当前的代码:

<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>

解决方案

我找到了最适合我的解决方案:

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:

<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:

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

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.

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. 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).

The problem is that the Tabs UI bar only accepts <li> because it's a <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.

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:

$(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:

<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:

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

这篇关于如何在jQuery中将UI对话框与UI选项卡结合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆