Demo of refreshPosition option for Dragging elements in JQuery UI

Drag me around












HTML

<div id="draggable" class='drg_box'>
  <p>Drag me around</p>
</div>
<br><br><br><br><br><br><br>
<button  id=b1>refreshPosition : true </button><button  id=b2>refreshPosition false</button>
<div id=d1></div>

jquery

<script>
$(document).ready(function() {
////////////////
$( "#draggable" ).draggable({
refreshPosition: true
});
//////
$("#b1").click(function(){
$( ".drg_box" ).draggable( "option", "refreshPosition", true );
var refreshPosition = $( ".drg_box" ).draggable( "option", "refreshPosition" );
$('#d1').html("refreshPosition value is " + refreshPosition);
})
//////////////
$("#b2").click(function(){
$( ".drg_box" ).draggable( "option", "refreshPosition", false );
var refreshPosition = $( ".drg_box" ).draggable( "option", "refreshPosition" );
$('#d1').html("refreshPosition value is " + refreshPosition);
})
//////////////

var refreshPosition = $( ".drg_box" ).draggable( "option", "refreshPosition" );
$('#d1').html("refreshPosition value is " + refreshPosition);
/////
///////////
})
</script>