繁体   English   中英

是否可以将Jcrop与jQuery contextMenu结合使用?

[英]Is it possible to combine Jcrop with jQuery contextMenu?

我尝试了一些简单的实现方式(例如,将鼠标移到上面,启用contextmenu),但看来这种方式行不通。 可能是zIndex问题吗?

$(function($) {
    $('#test').Jcrop({
        aspectRatio: 1,
        maxSize: [64, 64],
        onSelect: testFunc
    });
});

function testFunc() {
    console.log("onSelect - testFunc()");
    $.contextMenu({
        selector    : '#test',
        items       : {
            "edit": {name: "Edit", icon: "edit"},
            "cut": {name: "Cut", icon: "cut"}
       }
    });
    console.log("contextMenu"); // Appears to be called but the contextmenu does not appear
}

看看这个小提琴

jQuery contextMenu插件创建一个右键单击时显示的上下文菜单。 如果要使其与JCrop一起使用,则需要禁用默认触发器(右键单击),并从JCrop onSelect手动显示contextMenu。

$(function($) {
  $('#test').Jcrop({
    aspectRatio: 1,
    maxSize: [64, 64],
    onSelect: testFunc
  });

  $.contextMenu({
    selector    : '#test',
    trigger     : 'none', // disable right click trigger
    items       : {
      "edit": {name: "Edit", icon: "edit"},
      "cut": {name: "Cut", icon: "cut"}
    }
  });
});

function testFunc() {
  // Manually display ContextMenu from registered selector
  $('#test').contextMenu();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM