jQueryUI - 标签用法

时间:2013-08-28 04:14:22

标签: javascript jquery html ajax iframe

我很擅长编程尝试创建Web应用程序,可以在不重新加载菜单的情况下更改内容。

然后我决定使用垂直jquery-ui标签作为导航器。使用此代码

<div id="tabs">
     <ul>
        <li><center>Market Data</center></li>
        <li><a href="t1.htm">For Test 1</a></li>
        <li><a href="t2.htm">For Test 2</a></li>
        <li><a href="t3.htm">For Test 3</a></li>
     </ul>
</div>

问题是jquery-ui的这个“标签”使用什么机制来显示其中的另一个htm文件AJAX,iframe或什么?

这是一个好方法吗?

它可以处理复杂的htm文件,涉及提交表单,从Web服务接收数据吗?

提前谢谢!

编辑:很抱歉没有提到这个,但我想尽可能避免使用AJAX。

3 个答案:

答案 0 :(得分:0)

您可以使用jquery-ui的“tabs”。像这样:

<!doctype html>
<html lang="en">

    <head>
        <meta charset="utf-8" />
        <title>jQuery UI Tabs - Default functionality</title>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"
        />
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css" />
        <script>
            $(function () {
                $("#tabs").tabs();
            });
        </script>
    </head>

    <body>
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">Nunc tincidunt</a>
                </li>
                <li><a href="#tabs-2">Proin dolor</a>
                </li>
                <li><a href="#tabs-3">Aenean lacinia</a>
                </li>
            </ul>
            <div id="tabs-1">
                <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur
                    nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper
                    ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus.
                    Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing.
                    Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam
                    molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor
                    nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
            </div>
            <div id="tabs-2">
                <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante,
                    ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed
                    fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut
                    tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed
                    ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing
                    adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel
                    metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis.
                    Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod
                    felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.</p>
            </div>
            <div id="tabs-3">
                <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam
                    vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue
                    orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu
                    ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales.
                    Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit
                    ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec,
                    luctus a, lacus.</p>
                <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at,
                    magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque.
                    Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede
                    vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor
                    eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo.
                    Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae,
                    pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo.
                    Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit
                    hendrerit.</p>
            </div>
        </div>
    </body>

</html>

答案 1 :(得分:0)

HTML页面的加载是使用AJAX完成的,这是一个很好的方法,你也可以使用HTML页面调用Web服务..你可以没有问题..

有关详细信息,请参阅http://jquerytools.org/demos/tabs/ajax.html http://jqueryui.com/tabs/#ajax

答案 2 :(得分:0)

here 您可以看到此内容中的标签示例来自ajax

jquery ui tabs可根据您的要求轻松定制

代码

<!doctype html>
<html lang="en">

    <head>
        <meta charset="utf-8" />
        <title>jQuery UI Tabs - Content via Ajax</title>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"
        />
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css" />
        <script>
            $(function () {
                $("#tabs").tabs({
                    beforeLoad: function (event, ui) {
                        ui.jqXHR.error(function () {
                            ui.panel.html("Couldn't load this tab. We'll try to fix this as soon as possible. " + "If this wouldn't be a demo.");
                        });
                    }
                });
            });
        </script>
    </head>

    <body>
        <div id="tabs">
            <ul>
                <li><a href="#tabs-1">Preloaded</a>
                </li>
                <li><a href="ajax/content1.html">Tab 1</a>
                </li>
                <li><a href="ajax/content2.html">Tab 2</a>
                </li>
                <li><a href="ajax/content3-slow.php">Tab 3 (slow)</a>
                </li>
                <li><a href="ajax/content4-broken.php">Tab 4 (broken)</a>
                </li>
            </ul>
            <div id="tabs-1">
                <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur
                    nec arcu. Donec sollicitudin mi sit amet mauris. Nam elementum quam ullamcorper
                    ante. Etiam aliquet massa et lorem. Mauris dapibus lacus auctor risus.
                    Aenean tempor ullamcorper leo. Vivamus sed magna quis ligula eleifend adipiscing.
                    Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam
                    molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut dolor
                    nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.</p>
            </div>
        </div>
    </body>

</html>