javascript - "Rebind" a slider after calling .unbind()? -


i unbind slider disable people moving , down after game has ended, when click play again, slider should re-bound work again.

inside startgame() function called after init() called on gamereset():

$( "#myslider" ) .on('mousedown', slidermousedown) .on('touchstart', slidermousedown) .slider({   orientation: "vertical",   range: "min",   min: 0,   max: 100,   value: 0,   step: 1,   animate: "slow",   slide: refreshswatch,   change: refreshswatch }); 

that code works fine 'setting up' slider when gamereset() calls startgame() code again, doesn't seem "re-bind" sliders. don't think i'm doing correctly, there way?

the code use unbind on gameended() is:

$("#myslider").unbind(); 

instead of unbind try destroy

$("#myslider").slider( "destroy" ); 

or can disable , enable slider

in gameended()

$( "#myslider" ).slider( "disable" ); 

and in gamereset()

$( "#myslider" ).slider( "enable" ); 

Comments