events.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Menu Events - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>Menu Events</h2>
  14. <p>Right click on page to display menu and click an item.</p>
  15. <div style="margin:20px 0;"></div>
  16. <div id="mm" class="easyui-menu" data-options="onClick:menuHandler" style="width:120px;">
  17. <div data-options="name:'new'">New</div>
  18. <div data-options="name:'save',iconCls:'icon-save'">Save</div>
  19. <div data-options="name:'print',iconCls:'icon-print'">Print</div>
  20. <div class="menu-sep"></div>
  21. <div data-options="name:'exit'">Exit</div>
  22. </div>
  23. <div id="log" class="easyui-panel" title="Event Log" style="height:250px;padding:10px">
  24. </div>
  25. <script>
  26. function menuHandler(item){
  27. $('#log').prepend('<p>Click Item: '+item.name+'</p>');
  28. }
  29. $(function(){
  30. $(document).bind('contextmenu',function(e){
  31. e.preventDefault();
  32. $('#mm').menu('show', {
  33. left: e.pageX,
  34. top: e.pageY
  35. });
  36. });
  37. });
  38. </script>
  39. </body>
  40. </html>