Comments (3)
I have not seen this error before. It seems like $
is defined, but $.ui
is not. So query-1.11.1.min.js
was loaded, but jquery-ui.min.js
was not.
You could add some logging there, to verify.
I also noticed an id="jquery-ui-lib"
attribute: is there any dynamic magic happening to modify or add header script tags?
from jquery-ui-contextmenu.
Answering your question... yes. Those script tags and link tags are added dynamically.
I found a way to avoid this issue. Maybe it will be a good idea to implement something like this in your plugin before start it. Before this part maybe **var supportSelectstart = "onselectstart" in document.createElement("div") ... **
/**
* This var will indicate if jquery ui is already loaded or not
*/
var jqueryUiIsLoaded;
/**
* Add context menu to document
*/
function addContextMenuToDocument() {
jqueryUiIsLoaded = setTimeout(function(){
// check if jquery ui was loaded
if ($.ui) {
// bind contextmenu event to document
addContextMenu();
// stop this check to continue executing
stopChecking();
}
}, 300);
}
/**
* Stop to look for jquery ui
*/
function stopChecking() {
clearTimeout(jqueryUiIsLoaded);
}
/**
* Bind contextmenu event to document
*/
function addContextMenu() {
// apply jquery ui context menu to any element on the page
$(document).contextmenu({
delegate: "body",
autoFocus: true,
preventContextMenuForPopup: true,
preventSelect: true,
taphold: true,
menu: [{
title: "Cut",
cmd: "cut",
uiIcon: "ui-icon-scissors",
}, {
title: "Copy",
cmd: "copy",
uiIcon: "ui-icon-copy",
}, {
title: "Paste",
cmd: "paste",
uiIcon: "ui-icon-clipboard",
}]
});
}
/**
* Jquery page ready listener function
*/
$(function() {
addContextMenuToDocument();
});
from jquery-ui-contextmenu.
Maybe it will be a good idea to implement something like this in your plugin before start it.
jQuery UI is simply a requirement for this plugin, and don't think that it is the responsibility of plugins to wait for all dependencies to be loaded.
The root problem seems to be that you initialize on page load
$(function() {
...
}
which is too early in your case. Instead you should initialize in the ready-event (or similar) of your loader.
Most AMD loaders, like requirejs offer callbacks or other mechanisms for this.
from jquery-ui-contextmenu.
Related Issues (20)
- Punctuation characters in "cmd" cause JavaScript error HOT 3
- How to use ContextMenu with HTML HOT 1
- Custom Icon issue HOT 1
- passing data from selected item to the select function HOT 4
- open an existing menu by left click HOT 1
- Problem running in Electron HOT 1
- Uncaught TypeError: $(...).zIndex is not a function #1 HOT 3
- jquery-migrate-3.0.0.js warning HOT 4
- What parameter in .contextmenu is used to indicate that context menu should appear on hover? HOT 1
- Context menu on hover and hide when not hover HOT 2
- Blur is fired even when I moved between context menu items HOT 1
- Contextmenu when element has no children HOT 2
- Can't create two contextmenu for the same wrapper element (document) HOT 2
- menu item title dash "-" is not showing, but showing as seperator HOT 5
- Destroy throws error HOT 2
- Live demo error HOT 1
- Checking if a context menu is opened/closed or destroyed HOT 2
- Typescript definitions? HOT 3
- disabled handler / issues HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-ui-contextmenu.