表格中有复选框。我想在右键单击行时逐行检查。
正确使用点击工作。当我点击右键时我想要。
请检查我的代码:
<?php if (isset($sub_folders)) { ?>
<?php foreach ($sub_folders as $sub_folder) { ?>
<tr id="<?php echo $sub_folder['id']; ?>" class="check <?php if (($sub_folder['is_file']) == 0) { ?>folder-row<?php } ?> td_bgcolor" >
<td><input type="checkbox" id="<?php echo $sub_folder['id']; ?>" class="check_row selected_check"></td>
<td style="color: #c9302c"><b class="<?php if (($sub_folder['is_file']) == 0) { ?> glyphicon <?php if (($sub_folder['is_favorite']) == 1) { ?><?php echo 'glyphicon-star' ?><?php } else { ?><?php echo 'glyphicon-star-empty' ?><?php } ?><?php } ?> add-to-fav" title="Add To Favorite" id="<?php echo $sub_folder['id']; ?>"></b></td>
<td class="<?php if (($sub_folder['is_file']) == 0) { ?> vf-icon-folder <?php } else { ?> glyphicon glyphicon-file <?php } ?>"></td>
<td><?php if (($sub_folder['is_file']) == 0) { ?><a class="folder_click" id="<?php echo $sub_folder['id']; ?>"><?php } ?><?php echo $sub_folder['client_name']; ?></a></td>
<td class="text-center"><?php
if (isset($sub_folder['file_size'])) {
echo $sub_folder['file_size'];
}
?></td>
<td class="text-center"><?php if ($sub_folder['updated_date'] != '0000-00-00 00:00:00') { ?><?php echo date('d-m-Y H:m:s', strtotime($sub_folder['updated_date'])); ?><?php } else { ?><?php echo '-'; ?><?php } ?></td>
<td class="text-center"><?php echo $sub_folder['created_user']->first_name; ?> <?php echo $sub_folder['created_user']->last_name; ?></td>
<td></td>
</tr>
<?php } ?>
<?php } ?>
这是我的剧本
$('.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);
}
});
$(".custom-menu li").click(function () {
switch ($(this).attr("data-action")) {
case "copy_move":
alert("copy_move");
break;
case "view_details":
alert("view_details");
break;
case "rename":
alert("rename");
break;
case "delete":
alert("delete");
break;
}
$(".custom-menu").hide(100);
});
答案 0 :(得分:1)
您必须使用contextmenu()
方法右键单击tr。
$('tr.check').contextmenu(function(e){
$(this).find('input[type="checkbox"].check_row').prop('checked',true);
return false; // not display default menu.
});