user3694341
user3694341

Reputation: 11

Duplicate flipclock

Im using Flipclock for my website, my question is... How do I put more then 1 flipclock in a page?

If I try to duplicate them it doesnt work (As in copy paste the div tags and just rename them)

Any idea how to put more then 1 flipclock in a webpage?

http://flipclockjs.com/

This is what I get : http://i58.tinypic.com/k3xk0p.png

This is my code :

    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
        <link rel="stylesheet" href="../includes/flipclock.css" />

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

        <script src="../includes/flipclock.js"></script>
    <script type="text/javascript">
        var clock;

        $(document).ready(function () {
            var clock;

            clock = $('.clock').FlipClock({
                clockFace: 'DailyCounter',
                autoStart: false,
                callbacks: {
                    stop: function () {
                        $('.message').html('The clock has stopped!')
                    }
                }
            });

            clock.setTime(65000); /*60 = 1 Minute*/
            clock.setCountdown(true);
            clock.start();

        });
    </script>
        <style type="text/css">
        section
        {
            background-color:rgba(0, 0, 0, 0.45);
            width:900px;
            padding-top:5px;
            margin-left:10px;
            border:1px solid rgb(16, 16, 16);
        }   
        footer
        {
            position:relative;
            top:25px;
        }         
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
    <div class="clock" style="margin:2em;"></div>
    <div class="message"></div>
    <div class="clock" style="margin:2em;"></div>
    <div class="message"></div>
    </asp:Content>

Upvotes: 0

Views: 346

Answers (3)

billatron
billatron

Reputation: 45

I know this is an old post, but this might possibly help someone out in the future.

<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
<div id="clock1" class="clock" style="margin:2em;"></div>
<div class="message"></div>
<div id="clock2" class="clock" style="margin:2em;"></div>
<div class="message"></div>
</asp:Content>

Then just the jQuery div selector ($('#divName')) to instantiate your clocks.

<script type="text/javascript">
    var clock;

    $(document).ready(function () {
        var clock;

        clock = $('#clock1').FlipClock({
            clockFace: 'DailyCounter',
            autoStart: false,
            callbacks: {
                stop: function () {
                    $('.message').html('The clock has stopped!')
                }
            }
        });

        clock.setTime(65000); /*60 = 1 Minute*/
        clock.setCountdown(true);
        clock.start();

        clock = $('#clock2').FlipClock({
            clockFace: 'DailyCounter',
            autoStart: false,
            callbacks: {
                stop: function () {
                    $('.message').html('The clock has stopped!')
                }
            }
        });

        clock.setTime(65000); /*60 = 1 Minute*/
        clock.setCountdown(true);
        clock.start();

    });
</script>

Upvotes: 0

user3694341
user3694341

Reputation: 11

So I tried that and it fixed the way it looked, but there is still no countdown

This is what it looks like now http://i57.tinypic.com/kasizt.png

And here is the code

    <%@ Page Title="" Language="C#" MasterPageFile="~/GamerzBox.master" AutoEventWireup="true" CodeFile="ComingSoon.aspx.cs" Inherits="ComingSoon" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
        <link rel="stylesheet" href="../includes/flipclock.css" />

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

        <script src="../includes/flipclock.js"></script>
    <script type="text/javascript">
        var clock;

        $(document).ready(function () {
            var clock;

            clock = $('.clock').FlipClock({
                clockFace: 'DailyCounter',
                autoStart: false,
                callbacks: {
                    stop: function () {
                        $('.message').html('The clock has stopped!')
                    }
                }
            });

            clock.setTime(65000); /*60 = 1 Minute*/
            clock.setCountdown(true);
            clock.start();

        });
    </script>
    <script type="text/javascript">
            var clock2;

            $(document).ready(function () {
                var clock2;

                clock2 = $('.clock2').FlipClock({
                    clockFace: 'DailyCounter',
                    autoStart: false,
                    callbacks: {
                        stop: function () {
                            $('.message').html('The clock has stopped!')
                        }
                    }
                });

                clock.setTime(65000); /*60 = 1 Minute*/
                clock.setCountdown(true);
                clock.start();

            });
    </script>
        <style type="text/css">
        section
        {
            background-color:rgba(0, 0, 0, 0.45);
            width:900px;
            padding-top:5px;
            margin-left:10px;
            border:1px solid rgb(16, 16, 16);
        }   
        /*footer
        {
            position:relative;
            top:25px;
        }*/         
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
    <div class="clock" style="margin:2em;"></div>
    <div class="message"></div>
    <div class="clock2" style="margin:2em;"></div>
    <div class="message2"></div>
</asp:Content>

Upvotes: 0

surajck
surajck

Reputation: 1175

Initialize a new instance of FlipClock, maybe that'll do the trick. And choose different class names:

<div class="clockTwo" style="margin:2em;"></div>

And the JS:

clockTwo = $('.clockTwo').FlipClock({
            clockFace: 'DailyCounter',
            autoStart: false,
            callbacks: {
                stop: function () {
                    $('.message').html('The clock has stopped!')
                }
            }
        });

Upvotes: 1

Related Questions