且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何添加AJAX加载到尼尔·多尔蒂的科达滑块?

更新时间:2022-10-15 15:50:12

最简单的方法是将其存储在一个HTML文件,并使用负载检索()

直接从jQuery的文档:

  $('#结果)的负载(AJAX / test.html的#container的')。
 

  

在这种方法执行,它将检索的AJAX / test.html中的内容,但随后的jQuery解析返回的文档查找与容器的标识元素。该元件中,伴随着它的内容,被插入元件与结果的ID,并且所检索的文档的其余部分被丢弃。

如果这仍然缓慢只是多页拆分它,只加载一个页面的时间

  $('#结果)的负载(AJAX / test.html的')。
 

我不能完全肯定这一点的***方式,但你可以这样做:

 <脚本类型=文/ JavaScript的SRC =JavaScript的/ jQuery的-1.3.2.min.js>< / SCRIPT>
    <脚本类型=文/ JavaScript的SRC =JavaScript的/ jquery.easing.1.3.js>< / SCRIPT>
    <脚本类型=文/ JavaScript的SRC =JavaScript的/ jquery.coda滑盖-2.0.js>< / SCRIPT>
     <脚本类型=文/ JavaScript的>
        $()。就绪(函数(){
            $('#尾滑块-1')codaSlider()。
            $(#PANEL1)负载(panel1.html); //填充上负载
            $(li.tab1一)。点击(函数(){
                $(#PANEL1)的负载(panel1.html); //填充上点击
            });
            $(li.tab2一)。点击(函数(){
                $(#是Panel2)负载(panel2.html);
            });
        });

     < / SCRIPT>
 

添加一个id为DIV CLASS =面板包装ID = PANEL1

 < D​​IV CLASS =结尾,滑盖包装>
        < D​​IV CLASS =结尾滑盖preLOADID =结尾滑盖-1>
            < D​​IV CLASS =面板>
                < D​​IV CLASS =面板包装ID =PANEL1>
                    < H2类=头衔 -  GT;面板1 LT; / H>
                    &其中p为H.;&所述; / P>
                < / DIV>
            < / DIV>
            < D​​IV CLASS =面板>
                < D​​IV CLASS =面板包装ID =是Panel2>
                    < H2类=头衔 -  GT;图2'; / H>
                    &其中p为H.;&所述; / P>
                < / DIV>
            < / DIV>
            < D​​IV CLASS =面板>
                < D​​IV CLASS =面板包装ID =·Panel3中>
                    < H2类=头衔 -  GT;小组第3版; / H>
                    < P>评级机构luctus燕雀奥迪奥VEL hendrerit。信用评级机构枕auctor sollicitudin。桑达拉克丝华富,sodales坐阿梅德feugiat坐阿梅德,灵猫NEC augue。桑达enim存有,malesuada QUIS blandit德维尔,posuere eget ERAT。桑达一个arcu胡斯托。整数ultricies,NUNC在lobortis facilisis,ligula拉克丝前庭华富,在velit ID tincidunt SAPIEN arcu。前庭consequat augue等turpis condimentum油树SED简历metus。 Morbi狮子座的***人,tincidunt lobortis发酵eget,rhoncus韦尔SEM。 Morbi山雀灵猫velit VEL的Tempus。 Morbi enim turpis,facilisis韦尔volutpat时,condimentum QUIS ERAT。 Morbi auctor rutrum***人SED placerat。 Etiam存有velit,eleifend在vehicula欧盟,tristique一个存有。 Donec简历华富德维尔直径iaculis必比登eget UT直径。 Fusce QUIS interdum直径。 UT斯达康乌仁娜胡斯托,dapibus一个腾邦坐阿梅德,必比登在lectus。桑达venenatis molestie commodo< / P>
                < / DIV>
 

I'm implementing Niall Doherty's Coda Slider into the body of a webpage. The problem with this is the amount of content my client has gives the page a massive load time.

What I would like to do is to split the content off into seperate html files and upon clicking on the tab trigger, load the content, then animate the switch.

I honestly have no idea how to do this so I sadly can't provide any faux code in an effort to help illustrate my point. Any and all help will be very appreciated. I have searched around the Coda Forums for such a solution but all I've gotten is people claiming to have it and no intent to help.

Cheers.

The simplest way would be to store it in one html-file and retrieve it using load()

straight from the jquery docs:

$('#result').load('ajax/test.html #container');

When this method executes, it retrieves the content of ajax/test.html, but then jQuery parses the returned document to find the element with an ID of container. This element, along with its contents, is inserted into the element with an ID of result, and the rest of the retrieved document is discarded.

If this is still to slow just split it up in multiple pages and just load one page at a time

$('#result').load('ajax/test.html');

I'm not entirely sure this the best way but you could do:

    <script type="text/javascript" src="javascripts/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="javascripts/jquery.easing.1.3.js"></script>
    <script type="text/javascript" src="javascripts/jquery.coda-slider-2.0.js"></script>
     <script type="text/javascript">
        $().ready(function() {
            $('#coda-slider-1').codaSlider();
            $("#panel1").load("panel1.html");//populate on load
            $("li.tab1 a").click(function() {
                $("#panel1").load("panel1.html");//populate on click
            });
            $("li.tab2 a").click(function() {
                $("#panel2").load("panel2.html");
            });
        });

     </script>

Add an id to div class="panel-wrapper" id="panel1"

<div class="coda-slider-wrapper">
        <div class="coda-slider preload" id="coda-slider-1">
            <div class="panel">
                <div class="panel-wrapper" id="panel1">
                    <h2 class="title">Panel 1</h2>
                    <p></p>
                </div>
            </div>
            <div class="panel">
                <div class="panel-wrapper" id="panel2">
                    <h2 class="title">Panel 2</h2>
                    <p></p>
                </div>
            </div>
            <div class="panel">
                <div class="panel-wrapper" id="panel3">
                    <h2 class="title">Panel 3</h2>
                    <p>Cras luctus fringilla odio vel hendrerit. Cras pulvinar auctor sollicitudin. Sed lacus quam, sodales sit amet feugiat sit amet, viverra nec augue. Sed enim ipsum, malesuada quis blandit vel, posuere eget erat. Sed a arcu justo. Integer ultricies, nunc at lobortis facilisis, ligula lacus vestibulum quam, id tincidunt sapien arcu in velit. Vestibulum consequat augue et turpis condimentum mollis sed vitae metus. Morbi leo libero, tincidunt lobortis fermentum eget, rhoncus vel sem. Morbi varius viverra velit vel tempus. Morbi enim turpis, facilisis vel volutpat at, condimentum quis erat. Morbi auctor rutrum libero sed placerat. Etiam ipsum velit, eleifend in vehicula eu, tristique a ipsum. Donec vitae quam vel diam iaculis bibendum eget ut diam. Fusce quis interdum diam. Ut urna justo, dapibus a tempus sit amet, bibendum at lectus. Sed venenatis molestie commodo.</p>
                </div>