How to put the stored values from local-storage back to range slider?

How to put the stored values from local-storage back to range slider?

Here are two slider fiddle examples:



I'm using local-storage to store the last max and min values of each range slider in the stop: function (event, ui). Each slider has their own key as shown in the Console. But I have trouble retrieving the values and putting them back to the sliders. They are showing `[object Object] - [object Object] ` instead of the stored values. Can anyone show me how to get it to work? 

HTML:

  1.     <h4>Width</h4>
  2.     <div data-max="100" data-min="0" class="slider"></div>
  3.     <input type="text" class="center amount">
  4.     <h4>Diameter</h4>
  5.     <div data-max="50" data-min="0" class="slider"></div>
  6.     <input type="text" class="center amount">
  7.     <h4>Thickness</h4>
  8.     <div data-max="20" data-min="0" class="slider"></div>
  9.     <input type="text" class="center amount">


jQuery:

  1.     $( ".slider" ).each(function(){
  2.       var datamax = $(this).data('max'),
  3.           datamin = $(this).data('min'),
  4.           amount = $(this).next('.amount'),
  5.           $key = $(this).prev('h4').text();
  6.     
  7.       $(this).slider({
  8.     
  9.        range: true,
  10.     
  11.        min: 0,
  12.     
  13.        max: datamax,
  14.     
  15.        values: [ datamin, datamax ],
  16.     
  17.        slide: function( event, ui ) {
  18.     
  19.        amount.val( ui.values[ 0 ] + " - " + ui.values[ 1 ] +" mm");
  20.     
  21.        },
  22.        stop: function (event, ui) {
  23.             localStorage[$key] = ui.value+ "," + ui.values[ 1 ];
  24.     
  25.         }
  26.     
  27.       });
  28.         
  29.       if ($key in localStorage) 
  30.       {
  31.         var sliderValue = localStorage[$key];
  32.         console.log(sliderValue);
  33.         amount.val($( this ).slider( sliderValue, 0 ) +" - " + $( this ).slider( sliderValue, 1 )  +" mm");    
  34.       }
  35.       else
  36.       { 
  37.         amount.val($( this ).slider( "values", 0 ) +" - " + $( this ).slider( "values", 1 )  +" mm");
  38.       }    
  39.     });