Everyone!
I was working on a small project and i came across to this situation. One of my friend suggested me of using menu. I used following code as sample.
<script>
var gui = require('nw.gui'), db = require('diskdb'), fs = require("fs"), path = require('path');
var win = gui.Window.get();
var menu = new gui.Menu();
var info_item = new gui.MenuItem({ label: 'Which Fruit Do I Love?' });
menu.append(info_item);
menu.popup(500, 20);
var process = false, scr = 0, directory, w, h, ratio,canvas, base_, files_ = new Array(), files = new Array();
db = db.connect("lib/collections", ['libery', 'temp']);
.
.
</script>
It worked.And I thought lets try other way. So I added a little code at the bottom. But as soon as I changed code to this:
<script src="js/jquery.min.js"></script>
<script>
var gui = require('nw.gui'), db = require('diskdb'), fs = require("fs"), path = require('path');
var win = gui.Window.get();
var menu = new gui.Menu();
var info_item = new gui.MenuItem({ label: 'Which Fruit Do I Love?' });
menu.append(info_item);
var process = false, scr = 0, directory, w, h, ratio,canvas, base_, files_ = new Array(), files = new Array();
db = db.connect("lib/collections", ['libery', 'temp'])
$('body').on('contextmenu', function(ev) {
ev.preventDefault();
menu.popup(ev.x, ev.y);
return false;
});
</script>
Then I got error saying following:
Uncaught node.js Error
TypeError: undefined is not a function
at Menu.popup (menu.js:69:6)
at HTMLBodyElement.<anonymous> (file:///E:/projects/desktop%20app/lib/protype.html:138:10)
at HTMLBodyElement.x.event.dispatch (file:///E:/projects/desktop%20app/lib/js/jquery.min.js:5:9843)
at HTMLBodyElement.y.handle (file:///E:/projects/desktop%20app/lib/js/jquery.min.js:5:6633)
Then later i kept everything same and just moved of line of code below like this:
<script>
....
....
var process = false, scr = 0, directory, w, h, ratio,canvas, base_, files_ = new Array(), files = new Array();
db = db.connect("lib/collections", ['libery', 'temp']);
var menu = new gui.Menu();
var info_item = new gui.MenuItem({ label: 'Which Fruit Do I Love?' });
menu.append(info_item);
$('body').on('contextmenu', function(ev) { ...
....
</script>
And now amazing thing is it again gave error as bellow:
Uncaught node.js Error##
TypeError: undefined is not a function
at new Menu (menu.js:32:6) at file:///E:/projects/desktop%20app/lib/protype.html:134:14
I dont get it. Whats wrong with my code? I don't understand why does it says error. I have read the menu docs and I think there isn't anything wrong with my code. If there is then please do help me. And If anyone can please explain win in earth I am getting these error. Thank you.
Aucun commentaire:
Enregistrer un commentaire