2
I have an input that would like to change the date-min and data-max with the value brought by AJAX by changing the value of select category_id. Ajax is bringing the value correctly, but does not change the value of data-min and data-max.
HTML
<select id="category_id" class="form-control" name="category_id" required>
<option value="">Selecione</option>
@foreach($categories as $category)
<option value="{{$category->id}}">{{ $category->name }}</option>
@endforeach
</select>
<input type="text" id="range_01" data-min="0" data-max="0">
$("#category_id").change(function() {
var category = $(this).val();
$.ajax({
type:'GET',
url:'/customer/orders/lowerValueService/' + category,
success:function(data){
var value = data;
console.log(value);
$("#range_01").data("min", value);
},
error: function(){
console.log("Erro");
}
});
$.ajax({
type:'GET',
url:'/customer/orders/highestValueService/' + category,
success:function(data){
var value = data;
console.log(value);
$("#range_01").data("max", value);
},
error: function(){
console.log("Erro");
}
});
});
Forehead with
$("#range_01").attr("data-max", value);
, works?– Sergio
Didn’t work..
– Marcelo
I had done something wrong, it did work.
– Marcelo
The
.data()
jQuery works in a special way... where you need to use thisdata-xxx
in the code after you give it the value of ajax?– Sergio
It worked the way it went. You can put as answer.
– Marcelo
Yes, I’ll give you an answer, but I’m curious where you use that value, because it may be necessary to use it elsewhere, and I’d like to explain (to others who read the answer) why
.data
not work.– Sergio
Needed when changing select to change the date-min and date-max to use in another function.
– Marcelo
Ok, show this other function and the function that select runs when it changes as well.
– Sergio
This is the function of a plugin. http://ionden.com/a/plugins/ion.rangeSlider/en.html
– Marcelo