Skip to main content
4 of 5
change example code from "simple mode" to "mixed mode"
RTOSkit
  • 248
  • 3
  • 13

I do not quite understand, why in your code had so many passages from date to date,
if your "tag attribute" was already formed in the correct date?

I've done some adjustments in the code, I've tested and I do not see any kind of delay in the code or in the plugin.

This is the code and can see it working in live here:


function init_countdown(id,element,datetime,fullmode){
    var endDate = datetime;
    if(!fullmode){
       $(element).countdown({ date: endDate });
    }else{
        $(element).countdown({
          date: endDate,
          render: function(data) {
            var el = $(this.el);
            el.empty()
              .append("<div>" + this.leadingZeros(data.years, 4) + " <span>years</span></div>")
              .append("<div>" + this.leadingZeros(data.days, 3) + " <span>days</span></div>")
              .append("<div>" + this.leadingZeros(data.hours, 2) + " <span>hrs</span></div>")
              .append("<div>" + this.leadingZeros(data.min, 2) + " <span>min</span></div>")
              .append("<div>" + this.leadingZeros(data.sec, 2) + " <span>sec</span></div>");
          }
        });
    }
 }


$(function(){
  var mode=1;
  $.each($('.countdown'), function() {
    var _element = '.countdown-'+$(this).attr("id");
    var _id = $(this).attr("id");
    if($(_element).length > 0){
      var _datetime = $(_element).attr('data-expiration');
      init_countdown(_id,_element,_datetime,(mode^=1));
    }
  });
});

HTML:

  <body>
      <div id="25" class="span12 countdown label-expiring countdown-25" data-expiration="Jan 01, 2014 20:01:15">
      </div>
      <hr />
      <div id="26" class="span12 countdown label-expiring countdown-26" data-expiration="Jan 01, 2015 20:01:15">
      </div>
      <hr />      
       <div id="27" class="span12 countdown label-expiring countdown-27" data-expiration="Jan 01, 2016 20:01:15">
      </div>
  </body>​
RTOSkit
  • 248
  • 3
  • 13