title: jQuery UI Slider change and slide events report different results
body: <p>Okay, so a very similar question was asked here</p>
  
  <p><a href="https://stackoverflow.com/questions/9121160/jquery-ui-slider-value-returned-from-slide-event-on-release-is-different-fro">jQuery UI Slider - Value returned from &#39;slide&#39; event on release is different from &#39;change&#39; value</a></p>
  
  <p>But the answer was unsatisfactory in my opinion. Here is my JavaScript code: <a href="http://jsfiddle.net/AsDZJ/4/" rel="nofollow noreferrer">http://jsfiddle.net/AsDZJ/4/</a></p>
  
  <pre class="lang-js prettyprint-override"><code>function slideVal() {
      var number = $("#number_slider").slider("value");
      $("#number_field").append('Slide: ' + number + '&lt;br/&gt;');
  }
  
  function changeVal() {
      var number = $("#number_slider").slider("value");
      $("#number_field").append('Change: ' + number + '&lt;br/&gt;');
  }
  
  $(function() {
      $( "#number_slider" ).slider({
          min: 1,
          max: 10,
          change: changeVal,
          slide: slideVal
      });
  
      $( "#number_slider" ).slider( "value", 5 );
  });
  </code></pre>
  
  <p>The issue is that the slider is reporting different values between when the <em>change</em> handler is called, and when the <em>slide</em> handler is called.</p>
  
  <p>Now, the other question points out that if you declare the function anonymously, you can simply use ui.value, like so:</p>
  
  <pre class="lang-js prettyprint-override"><code>$( "#number_slider" ).slider({
      min: 1,
      max: 10,
      change: function(event, ui) {
          $("#number_field").append('Change: ' + ui.value + '&lt;br/&gt;');
      }
  });
  </code></pre>
  
  <p>This does give more consistent results, but also means that if, as in my case, I have a lot of complex logic to perform whenever the event changes, I have to repeat code. In addition, the calculations involve slider values from multiple sliders.</p>
  
  <p>How can I get access to the correct value from an explicitly declared function? Is this behavior in jQuery UI a bug?</p>
  
  <p>Thanks</p>