Adding method/function to jquery ui slider -


i trying add function/method jquery ui slider can play adding handle slider with. have slider right now:

var initialvalues = [180, 435, 1080, 1320]; // gives me 4 slider handles updatevalue = function (ui) { var hours = math.floor(ui.value / 60); var minutes = ui.value - (hours * 60);  if (hours.length == 1) hours = '0' + hours; if (minutes.length == 1) minutes = '0' + minutes; if (minutes == 0) minutes = '00'; if (hours >= 12) {     if (hours == 12) {         hours = hours;         minutes = minutes + " pm";     } else {         hours = hours - 12;         minutes = minutes + " pm";     } } else {     hours = hours;     minutes = minutes + " am"; } if (hours == 0) {     hours = 12;     minutes = minutes; } $(ui.handle).attr('data-value', hours + ':' + minutes); 

};

$(".pct-slider").slider({ min: 0, max: 1440, step: 15, range: false, values: initialvalues, create: function (event, ui) {     $.each( initialvalues, function(i, v){         updatevalue({             value: v,             handle: $('.ui-slider-handle').eq(i)          });     }); }, slide: function (event, ui) {     var handleindex = $('a', event.target).index(ui.handle),         curr = ui.values[handleindex],         next = ui.values[handleindex + 1] - 25,         prev = ui.values[handleindex - 1] + 25;      if (curr > next || curr < prev) {         return false;     }      updatevalue(ui);     positionselects(); }, addvalue: function( val ) {         //add code here testing value not in list         this.options.values.push(val);         this._refresh();     }, removevalue: function( ) {     this.options.values.pop( );     this._refresh(); } 

});

when call $( ".pct-slider" ).slider("addhandle"), "no such method 'addhandle' slider widget instance". whats issue , need can start messing functionality of this.

edit try call $( ".pct-slider" ).slider("addvalue(1400)") , no such method error. using jquery ui 1.10.4 also.

put before call slider.

(function ($) { $.widget('my-namespace.customslider', $.ui.slider, {     addvalue: function( val ) {         //add code here testing value not in list         this.options.values.push(val);         this._refresh();     },     removevalue: function( ) {         this.options.values.pop( );         this._refresh();     } }); })(jquery); 

then call slider this,

$("#slider").customslider({/* options */}); 

finally change slider values this,

$("#slider").customslider('addvalue', 5); 

you defining own jquery method... @ jfiddle see how works.

http://jsfiddle.net/ac2a3/5/

edit solution here... jquery ui - slider - how add values

that true. there no method called "addhandle", can see list of options jqueryui slider, here...

http://api.jqueryui.com/slider/


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -