0

我对尝试创建 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 或什么?

这是一个好方法吗?

它能否处理涉及提交表单、从 Web 服务接收数据的复杂 htm 文件?

先感谢您 !

编辑:抱歉之前没有提到这一点,但我想尽可能避免使用 AJAX。

4

3 回答 3

0

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

<!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>
于 2013-08-28T04:21:27.117 回答
0

在这里您可以看到此内容中的选项卡示例来自 ajax

jquery ui 选项卡 可根据您的要求轻松自定义

代码

<!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>
于 2013-08-28T04:29:23.283 回答
0

HTML 页面的加载是使用 AJAX 完成的,这是一种很好的方法,您也可以让 HTML 页面调用 Web 服务......你不会有任何问题......

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

于 2013-08-28T04:24:13.540 回答