-1

When I Right clicked in my Table Column. i get 3-5 alert screen. I Think there is any loop.. My Algorithms is When i clicked right get alert screen . if i press "OK" My Column is going to delete if i press "NO" My Column is not going to delete . But. When I press some options. I get 3-5 Alert screen too.. Can Anyone help me ?

$(".Stok_Satis").mousedown(function(ev) {


    if (ev.which == 3) //mouse sağ click 
    {
        id = $(this).attr("id");


        alert(Sil);
        if (confirm('Seçileni silmek istediğinize emin misiniz ?')) {
            if (Sil < 1) {
                Sil = 5;
                $("#satissatir #" + id).remove();
                removeByIndex(tablo, id);
                alert(tablo);
                i--;
                return;
                //return true   ;
            }
            //Sil=false;

        } else {
            Sil++;
            return;
            //Sil=false;
            //return false  ;       

        }
    } else if (ev.which == 1) //mouse sol click 
    {
        alert("sol click");
    }

});
htoniv
  • 1,658
  • 21
  • 40
Zarma Mokana
  • 71
  • 2
  • 10
  • Try adding `ev.stopPropagation()` add the top of the function. This will stop the mousedown executing twice or more by accident. – Gerrit Luimstra Jul 10 '16 at 21:35

1 Answers1

0

Here is a working sample for you. Just attach your logic under case 3. You will see that left click is captured by jQuery event however no action is taken.

$('body').mousedown(function(event) {
  switch (event.which) {
    case 1:
      break;
    case 2:
      alert('Middle Mouse button pressed.');
      break;
    case 3:
      alert('Right Mouse button pressed.');
      //Your code should come here
      break;
    default:
      alert('Unknown mouse click action.');
  }
});
<body>
  Test
</body>

Fiddle: https://jsfiddle.net/c08nfp09/

Ozan Gunceler
  • 1,067
  • 11
  • 20