if Condition returning false inside callback function
<p>I have got two <code>div</code> containers where I can drag and drop videos between these two containers.</p>

<p>Before dropping a <code>div</code>, I am checking whether this Video already exists inside the second <code>div</code> container or not.</p>

<p>If it doesn't exists inside the second <code>div</code> container then only I am dropping it or else doing nothing.</p>

<p>For this I am using the callback function stop to check this way </p>

<pre><code>stop: function(event, ui) {
  var video_id = $(ui.item).attr('video-id')
  var checker = checkifVideoExists(video_id);

  if (checker) {
    return false;
  } else {
    return true;
  }
}

function checkifVideoExists(videoid) {
  var flag = false;
  $("#excersisesinpac .portlet").each(function() {
    if ($(this).attr('video-id') === "" + videoid + "") {
      flag = true;
    } else {
      flag = false;
    }
  });
  return flag;
}
</code></pre>

<p>But unfortunately this condition is working only for when Video6 is dragged , but not for Video5 (Drag videos into second container only)</p>

<p><a href="https://jsfiddle.net/Lphf43wd/9/" rel="nofollow">https://jsfiddle.net/Lphf43wd/9/</a> </p>