Пользовательский меню щелкните правой кнопкойJquery

Программирование на jquery
Ответить Пред. темаСлед. тема
Anonymous
 Пользовательский меню щелкните правой кнопкой

Сообщение Anonymous »

http://jsfiddle.net/tnbym/
Я пытаюсь получить меню правого щелчка, чтобы показать только детям #canvas . Я также хочу, чтобы это удалило, когда ребенка не нажимают, но одна из проблем заключается в том, что документ называется, когда документ контейнера закрывает его до того, как действие будет вызвано. < /P>
if ( $("#tm").prop('checked') === true ) {
// Trigger action when the contexmenu is about to be shown
$("#canvas").find("*").bind("contextmenu", function (event) {
// Avoid the real one
event.preventDefault();
$("#custom-menu").hide(100);
// Show contextmenu
if ($("#showcustom-menu").show() === true) {
$("#custom-menu").hide(100).
// In the right position (the mouse)
css({
top: event.pageY + "px",
left: event.pageX + "px"
});
} else {
$("#custom-menu").show(100).
// In the right position (the mouse)
css({
top: event.pageY + "px",
left: event.pageX + "px"
});
}
});

// If the document is clicked somewhere
$(document).bind("mousedown", function () {
$("#custom-menu").hide(100);
});
} else {
$(document).unbind("contextmenu");
}
$("#tm").on('change', function() {
if ( $(this).prop('checked') === true ) {
// Trigger action when the contexmenu is about to be shown
$("#canvas").find("*").bind("contextmenu", function (event) {
// Avoid the real one
event.preventDefault();
$("#custom-menu").hide(100);
// Show contextmenu
if ($("#custom-menu").show() === true) {
$("#custom-menu").hide(100).
// In the right position (the mouse)
css({
top: event.pageY + "px",
left: event.pageX + "px"
});
} else {
$("#custom-menu").show(100).
// In the right position (the mouse)
css({
top: event.pageY + "px",
left: event.pageX + "px"
});
}
});

// If the document is clicked somewhere
$(document).bind("mousedown", function () {
$("#custom-menu").hide(100);
});
} else {
$(document).unbind("contextmenu");
}
});

// Menu's button actions
$("#custom-menu > button").click(function() {
alert($(this).text() + "was clicked");
});
$("#custom-menu > button#duplicate").click(function() {
// $('#canvas').append($(this).clone());
$("#custom-menu").hide(100);
});
$("#custom-menu > button#remove").click(function() {
// $(this).remove();
$("#custom-menu").hide(100);
});
$("#custom-menu").find("button#deselect, button#close").click(function() {
$("#custom-menu").hide(100);
});


Подробнее здесь: https://stackoverflow.com/questions/248 ... ren-of-div
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Jquery»