1

I would like to use jquery slider to adjust values between 0 and 100, and divide them with percentages

value 1 value 2 and value 3 can be each between 0-90 while the others can't be less than 5, let's thinks about the following values 33,33,34.

the slider should show 3 values and there should be option to move between the values (attached an image) i used jquery slider range, but it is not supporting 33,33 option, i attached the code (i am using angular directive but it's jquery so it looks the same)

enter image description here

if you have any idea how to help me fix this issue

or advice for another component that doing what i need

CODE:

$( "#slider-range" ).slider({
range: true,
min: 0,
max: 100,
values: [ $scope.rangeLeft, $scope.rangeRight ],
slide: function( event, ui ) {

    var left = ui.values[0];
    var center = ui.values[1];
    var right = 100 - Math.abs(Math.round(left + center));

    if (left  < 5 || left  > 95 ||
        center  < 5 || center  > 95 ||
        right  < 5 || right  > 95 ||
        left + center  >  95 ||
        center + right  > 95)
    {
        console.log(left + " " + center + " " + right);
        return false;
    }

    $("#slider-range-left").text(left + '%');
    $("#slider-range-center").text(center + '%');
    $("#slider-range-right").text(right + '%');
    console.log(left + " " + center + " " + right);
}
dreamweiver
  • 6,002
  • 2
  • 24
  • 39
Liad Livnat
  • 7,435
  • 16
  • 60
  • 98
  • angular js and jquery are two different things, usage of both is not recommended, as it would result in overkill – dreamweiver Feb 26 '14 at 09:28
  • @dreamweiver What you said is utterly stupid. I have seen many projects using both these frameworks. Mind that AngularJS is a MVC framework while jQuery makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler. – Foreever Feb 26 '14 at 10:23
  • @Liad Livnat Please add a fiddle. – Foreever Feb 26 '14 at 10:24
  • @Foreever: refer to point number 2 over here http://stackoverflow.com/questions/14994391/how-do-i-think-in-angularjs-if-i-have-a-jquery-background . it clearly states augmenting jquery with angular.js is not recommended as it will be a overkill. – dreamweiver Feb 26 '14 at 10:35
  • guys you are missing the point, the point wasn't angularjs with jquery i already tested several directives myself before doing it, the question was if you understand how can i accomplish 3 values choose from slider range – Liad Livnat Feb 26 '14 at 12:17
  • Similar question here http://stackoverflow.com/questions/3486371/combined-total-for-multiple-jquery-ui-sliders – PhoebeB Dec 09 '14 at 12:56

0 Answers0