Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right click custom menu is not working properly

Right click menu correctly works with its functions. But the issue is sometimes it is not working properly. In my view if right clicked on the table row checked the checkbox correctly but after I unchecked and try checked again with right click its not working.

$('.check').bind("contextmenu", function (event) {
    event.preventDefault();

    $(".custom-menu").finish().toggle(100).css({
        top: event.pageY + "px",
        left: event.pageX + "px"
    });
});


$(document).bind("mousedown", function (e) {
    if (!$(e.target).parents(".custom-menu").length > 0) {
        $(".custom-menu").hide(100);
    }
});


$('tr.check').contextmenu(function (e) {
    $cb = $(this).find('input[type="checkbox"].selected_check');
    $($cb).attr('checked', 'checked');
    populate_context_menu($cb);

    return false;
});
like image 220
Menaka Kariyawasam Avatar asked Oct 30 '22 20:10

Menaka Kariyawasam


1 Answers

I changed my code with some code lines, and its helps to me.

$(".custom-menu li").click(function () {

   $(".custom-menu").hide(100);
});

 function isExist(id) {
    for (var i = 0; i < values.length; i++) {
    if (values[i] == id) {
        return true;
    }
 }
  return false;
 }

 $('tr.check').contextmenu(function (e) {

    $cb = $(this).find('input[type="checkbox"].selected_check');
        var id = $($cb).attr('id');
        var result = isExist(id);

        if (!result) {
            $('.selected_check').attr('checked', false);
            $('.check').removeClass('highlight_row');
            $('.check').addClass('td_bgcolor');
        }

        $($cb).attr('checked', 'checked');

        populate_context_menu($cb);

           return false;
        });
like image 72
Menaka Kariyawasam Avatar answered Nov 09 '22 14:11

Menaka Kariyawasam