Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8199165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:06:56+00:00 2026-06-07T06:06:56+00:00

Iam creating a timer widget. Now I want to add a callback when the

  • 0

Iam creating a timer widget. Now I want to add a callback when the timer starts.
This is the code of the widget.

(function($, undefined) {
    var timer = null;
    var timervalue = [0, 0, 0, 0, 0, 0, 0, 0, 1];
    $.widget('ui.timer', {

        options: {
            showDays: null,
            showHours: null,
            showMinutes: null,
            showSeconds: null,
            separator: ':',
            showLabels: null,
            labels: ['Days', 'Hours', 'Minutes', 'Seconds'],
            isReverseCounter: true,
            getTimer: null,
            onStart: null
        },
        _create: function() {
            console.log($.ui.timer);
            $(this.element).bind('onStart', function(event, ui) {

            });

            $(this.element).width(0);
            $(this.element).addClass('ui-widget ui-widget-header ui-timer');
            if(this.options.showDays) {
                $('<div class="ui-widget ui-widget-content ui-timer-content">0</div>').appendTo(this.element);
                $('<div class="ui-widget ui-widget-content ui-timer-content">0</div>').appendTo(this.element);
                $('<div class="ui-widget ui-widget-content ui-timer-content">0</div>').appendTo(this.element);
                $(this.element).width($(this.element).width() + 198);
            }
            if(this.options.showHours) {
                if(this.options.showDays) {
                    $('<div class="ui-timer-separator-container"><label class="ui-timer-separator">' + this.options.separator + '</label></div>').appendTo(this.element);
                }
                $('<div class="ui-widget ui-widget-content ui-timer-content">0</div>').appendTo(this.element);
                $('<div class="ui-widget ui-widget-content ui-timer-content">0</div>').appendTo(this.element);
                $(this.element).width($(this.element).width() + 132);
            }
            if(this.options.showMinutes) {
                if(this.options.showHours) {
                    $('<div class="ui-timer-separator-container"><label class="ui-timer-separator">' + this.options.separator + '</label></div>').appendTo(this.element);
                }
                $('<div class="ui-widget ui-widget-content ui-timer-content">0</div>').appendTo(this.element);
                $('<div class="ui-widget ui-widget-content ui-timer-content">0</div>').appendTo(this.element);
                $(this.element).width($(this.element).width() + 132);
            }
            if(this.options.showSeconds) {
                if(this.options.showMinutes) {
                    $('<div class="ui-timer-separator-container"><label class="ui-timer-separator">' + this.options.separator + '</label></div>').appendTo(this.element);
                }
                $('<div class="ui-widget ui-widget-content ui-timer-content">0</div>').appendTo(this.element);
                $('<div class="ui-widget ui-widget-content ui-timer-content">0</div>').appendTo(this.element);
                $(this.element).width($(this.element).width() + 132);
            }
            if(this.options.showLabels) {
                $('<div class="ui-timer-labelPanel"></div>').appendTo(this.element);
                var labelPanel = $(this.element).find('.ui-timer-labelPanel');
                if(this.options.showDays) {
                    $('<label class="ui-timer-label">' + this.options.labels[0] + '</label>').width(176).appendTo(labelPanel);
                }
                if(this.options.showHours) {
                    $('<label class="ui-timer-label" style="margin-left:20px;">' + this.options.labels[1] + '</label>').width(112).appendTo(labelPanel);
                }
                if(this.options.showMinutes) {
                    $('<label class="ui-timer-label">' + this.options.labels[2] + '</label>').appendTo(labelPanel);
                }
                if(this.options.showSeconds) {
                    $('<label class="ui-timer-label">' + this.options.labels[3] + '</label>').appendTo(labelPanel);
                }
            }
        },
        _init: function() {
        },
        _start: function() {
            $(this.element).trigger('onStart',{ date: new Date()});
            if(this.options.isReverseCounter) {

            }
            else {
                setInterval(function() {
                    $('.ui-timer-separator').fadeOut();
                    $('.ui-timer-separator').fadeIn();
                }, 1000);
                timer = setInterval(function() {
                    $('.ui-timer-content:last').text(timervalue[5]);
                    $($('.ui-timer-content')[$('.ui-timer-content').length - 2]).text(timervalue[4]);
                    $($('.ui-timer-content')[$('.ui-timer-content').length - 3]).text(timervalue[3]);
                    $($('.ui-timer-content')[$('.ui-timer-content').length - 4]).text(timervalue[2]);
                    $($('.ui-timer-content')[$('.ui-timer-content').length - 5]).text(timervalue[1]);
                    $($('.ui-timer-content')[$('.ui-timer-content').length - 6]).text(timervalue[0]);
                    timervalue[5] += 1;
                    if(timervalue[5] == 10) {
                        timervalue[5] = 0;
                        timervalue[4]++;
                        if(timervalue[4] == 6) {
                            timervalue[4] = 0;
                            timervalue[3]++;
                            if(timervalue[3] == 10) {
                                timervalue[3] = 0;
                                timervalue[2]++;
                                if(timervalue[2] == 6) {
                                    timervalue[2] = 0;
                                    timervalue[1]++;
                                    if(timervalue[1] == 10) {
                                        timervalue[1] = 0;
                                        timervalue[0]++;
                                        if(timervalue[1] == 4 && timervalue[2] == 2) {
                                            timervalue[0] = 0;
                                            timervalue[1] = 0;
                                            timervalue[2] = 0;
                                            timervalue[3] = 0;
                                            timervalue[4] = 0;
                                            timervalue[5] = 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }, 1000);
            }
        },
        widget: function() {

        },
        destroy: function() {
        },
        _setOption: function(key, value) {
        },
        refresh: function() {

        },
        start: function() {
            this._start();
        },
        stop: function() {
            clearTimeout(timer);
            $('.ui-timer-separator').stop();
        },
        reset: function() {
        },
        pause: function() {
        }
    });
})(jQuery);

I try using the bind method and the trigger but nothing happened.
This is a sample of what I am trying to do following this link

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:06:57+00:00Added an answer on June 7, 2026 at 6:06 am

    Use the _trigger method.

    this._trigger('start', this);
    

    I updated your fiddle to show this – http://jsfiddle.net/tppSr/.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi there Iam creating a Paypal IPN and i have a pay now button
I am creating a timer job in VS for sharepoint, and I want to
I am creating a System.Timers.Timer aTimer = new System.Timers.Timer(); and want to access the
This post is related to: POSIX TIMER- Have multiple timers I want to call
I am creating a chart control chart1.ChartAreas.Add(area); chart1.series.add(time); //loop //get values of a and
I am creating hotel booking system which requires lots of modal dialogs. For this
Alright I've been creating some test code to try and clear the upload queue,
I am creating an service which is use Service Component ,I want to run
I am creating a simple game which after a 5 second timer expires and
I am creating an application. I am running a countdown timer and saving time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.