cgatian
cgatian

Reputation: 22994

JQuery Mobile Slider Not ReEnabling

So I think I am doing everything correct with my jquery mobile slider, but the control is not being re-enabled. I've made a pretty decent jsFiddle with it, in hopes someone will spot the error quickly.

On the fiddle you will see the jQuery moblie control. If you click and move the slider position the event will fire that the control value changed. If you end up changing the value more than 5 times within 20 seconds the control will lock up. You can think of this as being a cooldown period. Well after the control cools down it should be re-enabled for more mashing.

Problem is, the control never comes back from being disabled!

http://jsfiddle.net/Narq6/

Sample Javascript:

var sent = 0;
var disabled = false;

$('#slider-fill').on( 'slidestop', function()
                     {
                       send();
                       writeConsole(sent);                                           
                     })

function send()
{
 setTimeout(decrease, 4000);
    sent +=1;

  if(sent > 5)
  {
     $('#slider-fill').prop('disabled', 'disabled');

    disabled = true;
  }  
}
function decrease()
{
  if(sent > 0)
     sent -= 1;
 writeConsole('decrease'); 
 writeConsole(sent); 

  if(sent === 0)
  {
    //CODE TO DISABLE HERE!!!
    //LOOK HERE THIS IS WHERE I REMOVE THE DISABLE!!!
      writeConsole('no longer disabled!');     
     $('#slider-fill').prop('disabled', '');
    ///YOU LOOKED TOO FAR GO BACK A LITTLE BIT :D
  }
}

function writeConsole(message)
{
  var miniconsole = $('#miniConsole');
  var contents = miniconsole.html();
  miniconsole.html(contents + message + '<br/>' );
  miniconsole.scrollTop(10000);

}

Upvotes: 2

Views: 469

Answers (1)

Gajotres
Gajotres

Reputation: 57309

You were using incorrect enable/disable syntax.

This one is a coorect syntax:

$('#slider-fill').slider('disable');

and

$('#slider-fill').slider('enable');

Here's am working example made from your jsFiddle: http://jsfiddle.net/Gajotres/djDDr/

Upvotes: 2

Related Questions