Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic Bootstrap Tabs

I want my bootstrap tabs to automatically tab but when a tab is clicked i want the tabbing to pause for a certain amount of time or stop completely. Here is the piece of javascript i am using.

    var timer = null, 
    interval = 1000,
    value = 0;

$("#start").click(function() {
  if (timer !== null) return;
  timer = setInterval(function () {
      value = value+1;
      $("#input").val(value);
  }, interval); 
});

$("#stop").click(function() {
  clearInterval(timer);
  timer = null
});
like image 800
RogueWolf Avatar asked Dec 16 '22 06:12

RogueWolf


1 Answers

If you have not already solved it ... here is your fiddle you can check.

// Tab click event handler
$('a').on('click', function (e) {
    e.preventDefault();
    // Stop the cycle
    clearInterval(tabCycle);
    // Show the clicked tabs associated tab-pane
    $(this).tab('show');
    // Start the cycle again in a predefined amount of time
    setTimeout(function () {
        //tabCycle = setInterval(tabChange, 5000);
    }, 15000);
});

http://jsfiddle.net/ahLyZ/1/

like image 182
Pallab Avatar answered Jan 02 '23 04:01

Pallab