Search results

Open a dialog on ContextMenu item click in JavaScript (ES5) ContextMenu control

23 Mar 2023 / 2 minutes to read

This section explains about how to open a dialog on ContextMenu item click. This can be achieved by handling dialog open in select event of the ContextMenu.

In the following sample, Dialog will open while clicking Save As... item.

Copied to clipboard

var dialog = new ej.popups.Dialog({
    content: "This file can be saved as PDF",
    buttons: [{
        buttonModel: {
            isPrimary: true,
            content: 'Submit',
            cssClass: 'e-flat',
        click: function () {
    target: document.getElementById("container"),
    width: '200px',
    height: '110px'
// Render initialized Dialog

var menuItems = [
        text: 'Back'
        text: 'Forward'
        text: 'Reload'
        separator: true
        text: 'Save As...'
        text: 'Print'
        text: 'Cast'

var menuOptions = {
    target: '#target',
    items: menuItems,
    select: function(args) {
      if(args.item.text === 'Save As...') {

var menuObj = new ej.navigations.ContextMenu(menuOptions, '#contextmenu');
Copied to clipboard
<!DOCTYPE html><html lang="en"><head>
    <title>Essential JS 2</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="description" content="Essential JS 2">
    <meta name="author" content="Syncfusion">
    <link href="" rel="stylesheet">
    <link href="//" rel="stylesheet">
    <link href="//" rel="stylesheet">
    <link href="//" rel="stylesheet">
    <link href="//" rel="stylesheet">
    <link href="//" rel="stylesheet">
    <link href="//" rel="stylesheet">

    <!--style reference from app-->
    <link href="styles.css" rel="stylesheet">

    <!--system js reference and configuration-->
<script src="" type="text/javascript"></script>

    <div id="container">
        <div id="target">Right click / Touch hold to open the ContextMenu</div>
        <ul id="contextmenu"></ul>
        <div id="dialog"></div>

var ele = document.getElementById('container');
if(ele) { = "visible";
<script src="index.js" type="text/javascript"></script>
Copied to clipboard
#container {
    height: 100%;
    overflow: hidden;
    width: 100%;

#loader {
  color: #008cff;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;

#container {
  visibility: hidden;

.list {
  display: none;

#target {
  border: 1px dashed;
  height: 150px;
  padding: 10px;
  position: relative;
  text-align: justify;
  color: gray;
  user-select: none;