简体   繁体   中英

jquery plugin codaslider

I am trying to use codaslider plugin and it does not work for me. I think I am doing everyhtings right but still its not working. Can someone help me finding out what am I making mistake. Here is my code below. The problem is it does not slide from one panel to antoher. I already went through the documentation but I do not know what is the mistake i am making here.

<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="plugins/jquery.coda-slider-2.0.js"></script>
    <script type="text/javascript" src="plugins/jquery.easing.1.3.js"></script>
    <script type="text/javascript">
    $().ready(function() {
       $('#codaslider5').codaSlider({
           dynamicArrows: false,
           dynamicTabs: false
       });
    });
    </script>
    <style>
        #nav { width: 500px; background: blue; height: 50px; }
        ul { list-style: none; margin: 0; }
        #mainWrapper #nav ul li { float: left; margin-right: 40px; }
        #slider { width: 500px; background: red; overflow: hidden; }
        .codaslider { width: 1500px; background: greenyellow; }
        .panel { width: 500px; height: 100px; float: left; }
        .panel1 { background: green; }
        .panel2 { background: lightblue; }
        .panel3 { background: yellow; }
    </style>
    <title>title</title>
</head>
<body>
    <div id="mainWrapper">
        <div id="nav">
            <ul>
                <li class="tab1"><a href="#1">Panel 1</a></li>
                <li class="tab2"><a href="#2">Panel 2</a></li>
                <li class="tab3"><a href="#3">Panel 3</a></li>
            </ul>
        </div>
        <div id="slider">
            <div class="codaslider" id="codaslider5">
                <div class="panel panel1">
                    <h2>Panel 1</h2>
                    <p>This is panel 1</p>
                </div>
                <div class="panel panel2">
                    <h2>Panel 2</h2>
                    <p>This is panel 2</p>
                </div>
                <div class="panel panel3">
                    <h2>Panel 3</h2>
                    <p>This is panel 3</p>
                </div>
            </div>
        </div>
    </div>
</body>

Well, I must have been messing around with this for the past hour or so, wondering why it didn't work because like you because it all looked like it should be fine.

I think I found the solution. It seems to be that codaSlider is picky about the names you give to your slider objects - they must contain dashes and must be in sequential order.

Your slider is named '#codaslider5', you need to change this to '#coda-slider-1' (if you use 2, 3...n it doesn't work - presumably it expects you to actually have sliders 1, 2, 3, 4 if you want to use an ID of 5).

Here we go:

Change:

$('#codaslider5').codaSlider({

to

$('#coda-slider-1').codaSlider({


Next, change:

<div id="nav">

to

<div id="coda-nav-1">


Next, change:

<div class="codaslider" id="codaslider5">

to

<div class="coda-slider" id="coda-slider-1">


Or for lazyness here is the fixed file , and the diff .

This will mess with your CSS so you'll have to fix it. But hopefully this gets you back on track.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM