jQuery.each( response, function( product, data ) {
console.log(data);
var newdiv = '<label>'+data.label+'</label><div id="attr_'+data.slug+'_slider" opt="'+data.slug+'" class="attr_slider"></div>';
jQuery('#product_attr').append(newdiv);
jQuery(document).find('select#'+data.slug+' option:contains("обычно")').prop('selected', true);
var val = data.values;
var src = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTCWRzdOvbe2gjvayg5POvNhLAqBt3Sen5Z4Syy1sjBYr-7Gxg&s';
jQuery(document).find('div#attr_'+data.slug+'_slider').each(function(){
jQuery(this).slider({ min: 0, max: val.length-1, value: 2 }).slider("pips", { rest: "label", labels: val }).on("slidechange", function(e,ui) {
needle_id = jQuery(this).attr("opt"); needle_val = jQuery(this).find('.ui-slider-pip-selected').text();
jQuery(document).find('select#'+needle_id+' option:contains("'+needle_val+'")').prop('selected', true);
jQuery(this).find('.ui-slider-handle').css([ val => ({ opacity: (val/100)+(val/4) }), val => ({ filter: `grayscale( (val/100)+(val/4) )` }),][this.dataset.index](ui.value));
}).attr('data-index', i => i).find('.ui-slider-handle').html(`<img src="${src}">`);
});
});