Giter Club home page Giter Club logo

contextmenu.js's Introduction

ContextMenu.js provides a basic context menu control to a webpage using javascript and Bootstrap.


A simple javascript library which provides a basic context menu using javascript and Bootstrap

For more informaton:

Usage

  1. CSS changes
  • Add CCS links for ContextMenu, FontAwesome, and Bootstrap
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/slate/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css" />		
<link rel="stylesheet" type="text/css" href="/stylesheets/contexmenu.css" />
  1. HTML5 table row changes for the unique id
<div class="row">
    <div class="col-md-12">
        <table id="CustomerTable" class=”table table-striped tabled-bordered table-condensed table-hover”>
			<thead>
				<tr>
					<th>Id</th>
					<th>First Name</th>
					<th>Last Name</th>
					<th>EMail</th>
				</tr>
			</thead>
			<tbody>
				<tr id='1' class='contextMenu-target'>
					<td >1</td>
					<td>Daffy</td>
					<td>Duck</td>
					<td>[email protected]</td>
				</tr>
			</tbody>
		</table>
	</div>
</div>
  1. HTML5 add a context menu to the body right before the table
<nav id="context-menu" class="contextMenu">
	<ul class="contextMenu-items">
		<li class="contextMenu-item">
			<a href=" Display/" class="contextMenu-action" data-action="Display">
				<i class="fa fa-file-text-o"></i> Display</a>
		</li>
		<li class="contextMenu-item">
			<a href="Edit/" class="contextMenu-action" data-action="Edit">
				<i class="fa fa-edit"></i> Edit</a>
		</li>
		<li class="contextMenu-item">
			<a href="Delete/" class="contextMenu-action" data-action="Delete">
				<i class="fa fa-trash"></i> Delete</a>
		</li>
	</ul>
</nav>
  1. Javascript changes
  • Instantiation
var contexmenu = new ContextMenu(); 
  1. Add ContextMenu.js to page scripts
<script src="/javascripts/contexmenu.js" type="text/javascript"></script>

FAQ

  1. How do I get the context menu to disappear again?
  • Right or left click anywhere outside the table body, including the table header
  1. Can I still use the default document context menu?
  • Yes, just right click outside the table body

contextmenu.js's People

Contributors

wbwiltshire avatar

Watchers

James Cloos avatar jQueryScript avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.