Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
161
rated 0 times [  168] [ 7]  / answers: 1 / hits: 16456  / 10 Years ago, wed, july 23, 2014, 12:00:00

I've checked all of the questions on SO and I can't seem to find the answer. If I place integers directly into the fields then this works but I want to set the parameters dynamically when I set up my script



I'm running JQuery 1.11.1, JQuery UI stable (1.11.0) and touchpunch. I've debugged and the variables are all present and initialised when this is invoked. I've also tried wrapping in self-executing functions with the same results.



(The slide function can be disregarded)



This throws the exception



EDIT I've just noticed that if I click on the slider the exception is thrown but if I then press the right arrow key no exception is thrown and the amount is populated with the value property. I've pasted console output at the end of the question.



$(#slider).slider({
value: parseInt(window.settings.principal.minimum),
min: parseInt(window.settings.principal.minimum),
max: parseInt(window.settings.principal.maximum),
step: parseInt(window.settings.principal.increment),
slide: function(event, ui) {
$( #amount ).val( $ + $( #slider).slider( value));
}
});


However this WILL work



$(#slider).slider({
value: 500,
min: 500,
max: 10000,
step: 500,
slide: function(event, ui) {
$( #amount ).val( $ + $( #slider).slider( value));
}
});


Console Output



jQuery(#slider).slider(value); 
5000
jQuery(#slider).slider(min);
Error: no such method 'min' for slider widget instance
jQuery(#slider).slider(minimum);
Error: no such method 'minimum' for slider widget instance
jQuery(#slider).slider(max);
Error: no such method 'max' for slider widget instance
jQuery(#slider).slider(interval);
Error: no such method 'interval' for slider widget instance
jQuery(#slider).slider(step);
Error: no such method 'step' for slider widget instance
jQuery(#slider).slider(values);
[]

More From » jquery

 Answers
81

Give your variables (window.settings.principal.*) another look. I just copied your source code, replaced them with my own, and it worked, so your code seems to be fine. Make sure that they're not only valid numbers, but that they make sense in context.


[#70065] Tuesday, July 22, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sonja

Total Points: 541
Total Questions: 113
Total Answers: 114

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
sonja questions
Mon, Nov 30, 20, 00:00, 4 Years ago
Sun, Oct 11, 20, 00:00, 4 Years ago
Thu, May 21, 20, 00:00, 4 Years ago
Sun, Nov 10, 19, 00:00, 5 Years ago
Mon, Aug 26, 19, 00:00, 5 Years ago
;