I am printing out objects in two different ways in the console with these calls:
console.log(ui.handle)
console.log($(ui.handle))
console.log(ui) prints out this:
console.log($(ui.handle)) prints out like this:
There is a common "thing"value I need to get out of one of them. In the first I need data-value. Therefore I need a way of getting the 12:00 AM from it.
From the second, this "thing"/value I need to get is in more than 1 spot. 1. Under attributes -> data-value -> it is the nodeValue, textContent, and value 2. Under dataset -> value is 12:00 AM
I Have tried doing the following after printing out the objects, and do not get the correct value:
console.log(ui.handle.attributes.getNamedItem("data-value"))
console.log($(ui.handle).data('value'))
console.log(ui.handle.dataset["value"])
Someone please understand what I am trying to get and help me.
Here Is my JS code that initializes the slider:
$(".pct-slider#" + sliders[1])
.customSlider({
min: 0,
max: 1440,
step: 15,
range: false,
ticks: true,
values: initialValues,
create: function (event, ui) {
$.each( initialValues, function(i, v){
updateValue({
value: v,
handle: $(".pct-slider#" + sliders[1]).find('.ui-slider-handle').eq(i)
});
});
},
start: function(event, ui) {
//console.log(event)
console.log(ui.handle)
console.log($(ui.handle))
console.log($(ui.handle).data('value'))
console.log(ui.handle.dataset["value"])
console.log(" ")
console.log(" ")
var curHandles = $(".pct-slider#tuesdaySlider").find('.ui-slider-handle')
var dataValue
$.each(curHandles, function(i, v){
dataValue = $(".pct-slider#" + sliders[1]).find('.ui-slider-handle').eq(i).attr('data-value')
console.log(ui.handle.dataset.value + " " + dataValue)
if (ui.handle.dataset.value == dataValue) {
var last = $($(".pct-slider#" + sliders[1]).customSlider('values')).last()[0]
$(".pct-slider#" + sliders[1]).customSlider('addValue', last + 15)
return false
}
})
console.log("HELLO " + $(ui.handle).data('value'))
},
slide: function (event, ui) {
resize_colors(sliders[1]);
var handleIndex = $('a', event.target).index(ui.handle),
curr = ui.values[handleIndex],
next = ui.values[handleIndex + 1] - 15,
prev = ui.values[handleIndex - 1] + 15;
if (curr > next || curr < prev) {
return false;
}
updateValue(ui);
//positionSelects();
},
stop: function(event, ui){
resize_colors(sliders[1]);
}
});
****NOTE**** the call console.log(ui.handle.dataset["value"]) in the stop function will give me 12:00 AM, but I am needing to extract this value in the start function to prevent the slide based on the value.