Christine Christine - 1 year ago 112
Javascript Question

Jquery UI draggable start function code

Can someone explain me this start: function code?

$("#car, #boat, #soccer").draggable({
start: function(event, ui) {
if (!done)
return false;

Answer Source

done is a defined variable (mostly boolean), if it equals to true (and not false), then the user can drag #car, #boat, and #soccer. This can explain it

  var done = false;
  $('#tg-done').on('click', function(){
      ((done) ? done = false : done = true);
      $('p').text('`done` = ' + done);
  $(".draggable" ).draggable({
      start: function(event, ui) {
         if(!done) return false;

.draggable {
<script src=""></script>
<script src=""></script>
<button id="tg-done">Toggle `done`</button>
<p>`done` = false</p>

<div class="draggable"></div>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download