Set Value To Jquery Widget Slider
EDIT: Simpler explenation of the problem first. More detailed explanation below. I use some jquery widgets code to create a UI slider. The code is here: https://webgl2fundamentals.
Solution 1:
I had a closer look at your code and reduced it to the absolute minimum. It turns out you can supply the starting value of the angle simply by putting it into the empty options argument of the initiatior method: $("#example").gmanUnitCircle({value: -Math.PI/3});
. In my example I chose the value of -60° in radians.
$(function(){
var widget=$("#example").gmanUnitCircle({value: -Math.PI/3});
functionsetval(w,val){w.empty().data("gmanUnitCircle",null).gmanUnitCircle({value:val});}
$('input').on('input',function(ev){ setval(widget,ev.target.value*Math.PI/180); })
});
#ui { width: 200px;}
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><scriptsrc="https://code.jquery.com/ui/1.8.16/jquery-ui.min.js"></script><scriptsrc="https://webgl2fundamentals.org/webgl/resources/jquery.mousecapture.js"></script><scriptsrc="https://webgl2fundamentals.org/webgl/resources/jquery-gman-circle.js"></script><body><divclass="description">
Drag Circle
<p><inputtype="text"placeholder="enter an angle (deg)"></p></div><divid="example"></div>
I now added a work-around: Whenever you enter a number in the input field the widget will simply be re-created! It is probably not what you were looking for but it does the job very well.
Post a Comment for "Set Value To Jquery Widget Slider"