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 gi开发者_如何转开发ves 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>
精彩评论