B
B
booogabooo2015-10-12 22:47:26
JavaScript
booogabooo, 2015-10-12 22:47:26

How to overcome closestHandle is undefined?

I'm trying to implement this example
The site uses jquery 1.6.1
I have 2.1.4 (do not suggest another one)
The "slider" does not work
I get this in firebug:
TypeError: closestHandle is undefined
Code:

jQuery("#slider").slider({
  /*min: 0,*/
  /*max: 1000,*/
  values: [0,1000],
  range: true,
  animate: true,
  stop: function(event, ui) {
    jQuery("input#minCost").val(jQuery("#slider").slider("values",0));
    jQuery("input#maxCost").val(jQuery("#slider").slider("values",1));
    
    },
    slide: function(event, ui){
    jQuery("input#minCost").val(jQuery("#slider").slider("values",0));
    jQuery("input#maxCost").val(jQuery("#slider").slider("values",1));
    }
});

jQuery("input#minCost").change(function(){

  var value1=jQuery("input#minCost").val();
  var value2=jQuery("input#maxCost").val();

    if(parseInt(value1) > parseInt(value2)){
    value1 = value2;
    jQuery("input#minCost").val(value1);
  }
  jQuery("#slider").slider("values",0,value1);	
});

  
jQuery("input#maxCost").change(function(){
    
  var value1=jQuery("input#minCost").val();
  var value2=jQuery("input#maxCost").val();
  
  if (value2 > 1000) { value2 = 1000; jQuery("input#maxCost").val(1000)}

  if(parseInt(value1) > parseInt(value2)){
    value2 = value1;
    jQuery("input#maxCost").val(value2);
  }
  jQuery("#slider").slider("values",1,value2);
});



// фильтрация ввода в поля
  jQuery('input').keypress(function(event){
    var key, keyChar;
    if(!event) var event = window.event;
    
    if (event.keyCode) key = event.keyCode;
    else if(event.which) key = event.which;
  
    if(key==null || key==0 || key==8 || key==13 || key==9 || key==46 || key==37 || key==39 ) return true;
    keyChar=String.fromCharCode(key);
    
    if(!/\d/.test(keyChar))	return false;
  
  });


});

How to fix the problem?
Googled, in some places they suggest to make an explicit check for an integer type (I looked at stackoverflow, there are many solutions, but either I can’t file it for my own, or I have a problem elsewhere)
UPD: Link
UPD2: I solved it in a different way. The example used a separate library. I installed the full jquery-ui and everything went well (there most likely was a problem in the versions, since the tutorial is 11 years old)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2015-10-12
@allard

If it's recommended, do it =)

....
jQuery("#slider").slider("values",0,parseInt(value1));	
....
jQuery("#slider").slider("values",1,parseInt(value2));

And so, without a whole page example, you can’t figure it out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question