How to update values in Jquery range slider
I'm using jquery range slider. I have an ajax call and I set the slider values in that ajax call. The code is as follows:
$.ajax({
type: "POST",
url: '/api/get-prices/',
data: JSON.stringify(filters),
contentType: "application/json",
beforeSend: function (xhr, settings) {
let csrftoken = getCookie('csrftoken');
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
},
success: function (response) {
let min_price = parseInt(_.min(response['prices']));
let max_price = parseInt(_.max(response['prices']));
let price_slider = $("#vehicles #price-slider");
$.HSCore.components.HSSlider.init(price_slider);
price_slider.slider( "values", 0", min_price );
price_slider.slider( "values", 1, max_price );
price_slider.attr('data-min', min_price);
price_slider.attr('data-max', max_price);
price_slider.attr('data-default', min_price + ", " + max_price);
min_price_wrapper.html(addDotAsThousandSeparator(min_price) + "€");
max_price_wrapper.html(addDotAsThousandSeparator(max_price) + "€");
$.HSCore.components.HSSlider.init(price_slider);
},
error: function () {
}
})
When I do that in success function the slider is rendered fine and the labels which I see are fine. min_price is 12690 and max_price is 19711 and the slider which is rendered is as follows:

Everything seems fine. But when I start to slide those values are not correct. The start label is 30 instead of 12690 and the stop label is 35000 instead of 19711.
Any idea what am I doing wrong?
javascript jquery jquery-ui jquery-ui-slider rangeslider
add a comment |
I'm using jquery range slider. I have an ajax call and I set the slider values in that ajax call. The code is as follows:
$.ajax({
type: "POST",
url: '/api/get-prices/',
data: JSON.stringify(filters),
contentType: "application/json",
beforeSend: function (xhr, settings) {
let csrftoken = getCookie('csrftoken');
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
},
success: function (response) {
let min_price = parseInt(_.min(response['prices']));
let max_price = parseInt(_.max(response['prices']));
let price_slider = $("#vehicles #price-slider");
$.HSCore.components.HSSlider.init(price_slider);
price_slider.slider( "values", 0", min_price );
price_slider.slider( "values", 1, max_price );
price_slider.attr('data-min', min_price);
price_slider.attr('data-max', max_price);
price_slider.attr('data-default', min_price + ", " + max_price);
min_price_wrapper.html(addDotAsThousandSeparator(min_price) + "€");
max_price_wrapper.html(addDotAsThousandSeparator(max_price) + "€");
$.HSCore.components.HSSlider.init(price_slider);
},
error: function () {
}
})
When I do that in success function the slider is rendered fine and the labels which I see are fine. min_price is 12690 and max_price is 19711 and the slider which is rendered is as follows:

Everything seems fine. But when I start to slide those values are not correct. The start label is 30 instead of 12690 and the stop label is 35000 instead of 19711.
Any idea what am I doing wrong?
javascript jquery jquery-ui jquery-ui-slider rangeslider
Syntax Error:price_slider.slider( "values", 0", min_price );
– Twisty
Nov 19 '18 at 18:50
Are you using the jQuery UI Slider? If so, why are you setting data attributes on the element and not setting them when you init the.slider()? Also, where to you init the.slider()?
– Twisty
Nov 19 '18 at 18:52
add a comment |
I'm using jquery range slider. I have an ajax call and I set the slider values in that ajax call. The code is as follows:
$.ajax({
type: "POST",
url: '/api/get-prices/',
data: JSON.stringify(filters),
contentType: "application/json",
beforeSend: function (xhr, settings) {
let csrftoken = getCookie('csrftoken');
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
},
success: function (response) {
let min_price = parseInt(_.min(response['prices']));
let max_price = parseInt(_.max(response['prices']));
let price_slider = $("#vehicles #price-slider");
$.HSCore.components.HSSlider.init(price_slider);
price_slider.slider( "values", 0", min_price );
price_slider.slider( "values", 1, max_price );
price_slider.attr('data-min', min_price);
price_slider.attr('data-max', max_price);
price_slider.attr('data-default', min_price + ", " + max_price);
min_price_wrapper.html(addDotAsThousandSeparator(min_price) + "€");
max_price_wrapper.html(addDotAsThousandSeparator(max_price) + "€");
$.HSCore.components.HSSlider.init(price_slider);
},
error: function () {
}
})
When I do that in success function the slider is rendered fine and the labels which I see are fine. min_price is 12690 and max_price is 19711 and the slider which is rendered is as follows:

Everything seems fine. But when I start to slide those values are not correct. The start label is 30 instead of 12690 and the stop label is 35000 instead of 19711.
Any idea what am I doing wrong?
javascript jquery jquery-ui jquery-ui-slider rangeslider
I'm using jquery range slider. I have an ajax call and I set the slider values in that ajax call. The code is as follows:
$.ajax({
type: "POST",
url: '/api/get-prices/',
data: JSON.stringify(filters),
contentType: "application/json",
beforeSend: function (xhr, settings) {
let csrftoken = getCookie('csrftoken');
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
},
success: function (response) {
let min_price = parseInt(_.min(response['prices']));
let max_price = parseInt(_.max(response['prices']));
let price_slider = $("#vehicles #price-slider");
$.HSCore.components.HSSlider.init(price_slider);
price_slider.slider( "values", 0", min_price );
price_slider.slider( "values", 1, max_price );
price_slider.attr('data-min', min_price);
price_slider.attr('data-max', max_price);
price_slider.attr('data-default', min_price + ", " + max_price);
min_price_wrapper.html(addDotAsThousandSeparator(min_price) + "€");
max_price_wrapper.html(addDotAsThousandSeparator(max_price) + "€");
$.HSCore.components.HSSlider.init(price_slider);
},
error: function () {
}
})
When I do that in success function the slider is rendered fine and the labels which I see are fine. min_price is 12690 and max_price is 19711 and the slider which is rendered is as follows:

Everything seems fine. But when I start to slide those values are not correct. The start label is 30 instead of 12690 and the stop label is 35000 instead of 19711.
Any idea what am I doing wrong?
javascript jquery jquery-ui jquery-ui-slider rangeslider
javascript jquery jquery-ui jquery-ui-slider rangeslider
edited Nov 19 '18 at 7:47
Boky
asked Nov 19 '18 at 7:16
BokyBoky
3,85233676
3,85233676
Syntax Error:price_slider.slider( "values", 0", min_price );
– Twisty
Nov 19 '18 at 18:50
Are you using the jQuery UI Slider? If so, why are you setting data attributes on the element and not setting them when you init the.slider()? Also, where to you init the.slider()?
– Twisty
Nov 19 '18 at 18:52
add a comment |
Syntax Error:price_slider.slider( "values", 0", min_price );
– Twisty
Nov 19 '18 at 18:50
Are you using the jQuery UI Slider? If so, why are you setting data attributes on the element and not setting them when you init the.slider()? Also, where to you init the.slider()?
– Twisty
Nov 19 '18 at 18:52
Syntax Error:
price_slider.slider( "values", 0", min_price );– Twisty
Nov 19 '18 at 18:50
Syntax Error:
price_slider.slider( "values", 0", min_price );– Twisty
Nov 19 '18 at 18:50
Are you using the jQuery UI Slider? If so, why are you setting data attributes on the element and not setting them when you init the
.slider()? Also, where to you init the .slider()?– Twisty
Nov 19 '18 at 18:52
Are you using the jQuery UI Slider? If so, why are you setting data attributes on the element and not setting them when you init the
.slider()? Also, where to you init the .slider()?– Twisty
Nov 19 '18 at 18:52
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369909%2fhow-to-update-values-in-jquery-range-slider%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53369909%2fhow-to-update-values-in-jquery-range-slider%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Syntax Error:
price_slider.slider( "values", 0", min_price );– Twisty
Nov 19 '18 at 18:50
Are you using the jQuery UI Slider? If so, why are you setting data attributes on the element and not setting them when you init the
.slider()? Also, where to you init the.slider()?– Twisty
Nov 19 '18 at 18:52