How to get an onclick element to work with requirejs modules
up vote
0
down vote
favorite
I am working on a project that is using requirejs, and html. I have an HTML element that has an onclick event:
<li><a href="#" onclick="filesystem.newFloorplan()">New <p class="shortcut">(Ctrl + D)</p></a></li>
When this is clicked, its not working. Here is the main file that is invoking the code:
define(function (require) {
"use strict";
var $ = require('jquery'),
go = require('goJS');
require('bootstrap');
require('jqueryUI');
require('floorWarmingDesignTool-Floorplan');
if ($("#floorWarmingDesignTool").length === 0)
return;
function init()
require(['floorWarmingDesignTool-Floorplan'], function (fp, FloorplanFilesystem)
// Floorplan
var myFloorplan = new fp.Floorplan("myFloorplanDiv");
// Filesystem
var filesyestem = new fp.FloorplanFilesystem(myFloorplan, fp.FILESYSTEM_UI_STATE);
//var ui = new fp.FloorplanUI(myFloorplan, "ui", "myFloorplan", fp.GUI_STATE);
// Palettes - Node Data Arrays
var furniturePalette = new fp.FloorplanPalette("furniturePaletteDiv", myFloorplan, fp.FURNITURE_NODE_DATA_ARRAY);
var wallPartsPalette = new fp.FloorplanPalette("wallPartsPaletteDiv", myFloorplan, fp.WALLPARTS_NODE_DATA_ARRAY);
// Enable Hotkeys
var body = document.getElementById('floorWarmingDesignTool');
body.addEventListener("keydown", function (e)
var keynum = e.which;
if (e.ctrlKey)
e.preventDefault();
switch (keynum)
case 83: filesystem.saveFloorplan(); // ctrl + s
break;
case 79: filesystem.showOpenWindow(); // ctrl + o
break;
case 68: e.preventDefault(); filesystem.newFloorplan(); // ctrl + d
break;
case 82: filesystem.showRemoveWindow(); // ctrl + r
break;
case 49: ui.setBehavior('wallBuilding', myFloorplan); // ctrl + 1
break;
case 50: ui.setBehavior('dragging', myFloorplan); // ctrl + 2
break;
case 72: ui.hideShow('diagramHelpDiv'); // ctrl + h
break;
case 73: ui.hideShow('selectionInfoWindow'); // ctrl + i
break;
case 80: ui.hideShow('myPaletteWindow'); // ctrl + p
break;
case 69: ui.hideShow('myOverviewWindow'); // ctrl + e
break;
case 66: ui.hideShow('optionsWindow'); // ctrl + b
break;
case 71: ui.hideShow('statisticsWindow'); // ctrl + g
break;
);
// Default Model Data
myFloorplan.floorplanFilesystem.loadFloorplanFromModel(fp.DEFAULT_MODEL_DATA);
// See all exposed Floorplan classes
console.log(fp);
);
init();
console.log("Floor Warming Design Tool - Ready!");
);
Here is the snippet of code that is from another module:
define(function (require, exports)
"use strict";
Object.defineProperty(exports, "__esModule",
value: true
);
var $ = require('jquery'),
go = require('goJS');
if ($("#floorWarmingDesignTool").length === 0)
return;
/*
* Instance methods
* New Floorplan, Save Floorplan, Save Floorplan As, Load Floorplan, Remove Floorplan
* Show Open Window, Show Remove Window
* Set Current File Name, Get Current File Name
*/
// Create new floorplan (Ctrl + D or File -> New)
FloorplanFilesystem.prototype.newFloorplan = function ()
var floorplan = this.floorplan;
// checks to see if all changes have been saved
if (floorplan.isModified)
var save = confirm("Would you like to save changes to " + this.getCurrentFileName() + "?");
if (save)
this.saveFloorplan();
this.setCurrentFileName(this.UNSAVED_FILENAME);
// loads an empty diagram
var model = new go.GraphLinksModel;
// initialize all modelData
model.modelData = this.DEFAULT_MODELDATA;
floorplan.model = model;
floorplan.undoManager.isEnabled = true;
floorplan.isModified = false;
if (floorplan.floorplanUI)
floorplan.floorplanUI.updateUI();
floorplan.floorplanUI.updateStatistics();
exports.FloorplanFilesystem = FloorplanFilesystem;
);
How do I get this onclick to work?
Thank You advance-
javascript html requirejs prototype
add a comment |
up vote
0
down vote
favorite
I am working on a project that is using requirejs, and html. I have an HTML element that has an onclick event:
<li><a href="#" onclick="filesystem.newFloorplan()">New <p class="shortcut">(Ctrl + D)</p></a></li>
When this is clicked, its not working. Here is the main file that is invoking the code:
define(function (require) {
"use strict";
var $ = require('jquery'),
go = require('goJS');
require('bootstrap');
require('jqueryUI');
require('floorWarmingDesignTool-Floorplan');
if ($("#floorWarmingDesignTool").length === 0)
return;
function init()
require(['floorWarmingDesignTool-Floorplan'], function (fp, FloorplanFilesystem)
// Floorplan
var myFloorplan = new fp.Floorplan("myFloorplanDiv");
// Filesystem
var filesyestem = new fp.FloorplanFilesystem(myFloorplan, fp.FILESYSTEM_UI_STATE);
//var ui = new fp.FloorplanUI(myFloorplan, "ui", "myFloorplan", fp.GUI_STATE);
// Palettes - Node Data Arrays
var furniturePalette = new fp.FloorplanPalette("furniturePaletteDiv", myFloorplan, fp.FURNITURE_NODE_DATA_ARRAY);
var wallPartsPalette = new fp.FloorplanPalette("wallPartsPaletteDiv", myFloorplan, fp.WALLPARTS_NODE_DATA_ARRAY);
// Enable Hotkeys
var body = document.getElementById('floorWarmingDesignTool');
body.addEventListener("keydown", function (e)
var keynum = e.which;
if (e.ctrlKey)
e.preventDefault();
switch (keynum)
case 83: filesystem.saveFloorplan(); // ctrl + s
break;
case 79: filesystem.showOpenWindow(); // ctrl + o
break;
case 68: e.preventDefault(); filesystem.newFloorplan(); // ctrl + d
break;
case 82: filesystem.showRemoveWindow(); // ctrl + r
break;
case 49: ui.setBehavior('wallBuilding', myFloorplan); // ctrl + 1
break;
case 50: ui.setBehavior('dragging', myFloorplan); // ctrl + 2
break;
case 72: ui.hideShow('diagramHelpDiv'); // ctrl + h
break;
case 73: ui.hideShow('selectionInfoWindow'); // ctrl + i
break;
case 80: ui.hideShow('myPaletteWindow'); // ctrl + p
break;
case 69: ui.hideShow('myOverviewWindow'); // ctrl + e
break;
case 66: ui.hideShow('optionsWindow'); // ctrl + b
break;
case 71: ui.hideShow('statisticsWindow'); // ctrl + g
break;
);
// Default Model Data
myFloorplan.floorplanFilesystem.loadFloorplanFromModel(fp.DEFAULT_MODEL_DATA);
// See all exposed Floorplan classes
console.log(fp);
);
init();
console.log("Floor Warming Design Tool - Ready!");
);
Here is the snippet of code that is from another module:
define(function (require, exports)
"use strict";
Object.defineProperty(exports, "__esModule",
value: true
);
var $ = require('jquery'),
go = require('goJS');
if ($("#floorWarmingDesignTool").length === 0)
return;
/*
* Instance methods
* New Floorplan, Save Floorplan, Save Floorplan As, Load Floorplan, Remove Floorplan
* Show Open Window, Show Remove Window
* Set Current File Name, Get Current File Name
*/
// Create new floorplan (Ctrl + D or File -> New)
FloorplanFilesystem.prototype.newFloorplan = function ()
var floorplan = this.floorplan;
// checks to see if all changes have been saved
if (floorplan.isModified)
var save = confirm("Would you like to save changes to " + this.getCurrentFileName() + "?");
if (save)
this.saveFloorplan();
this.setCurrentFileName(this.UNSAVED_FILENAME);
// loads an empty diagram
var model = new go.GraphLinksModel;
// initialize all modelData
model.modelData = this.DEFAULT_MODELDATA;
floorplan.model = model;
floorplan.undoManager.isEnabled = true;
floorplan.isModified = false;
if (floorplan.floorplanUI)
floorplan.floorplanUI.updateUI();
floorplan.floorplanUI.updateStatistics();
exports.FloorplanFilesystem = FloorplanFilesystem;
);
How do I get this onclick to work?
Thank You advance-
javascript html requirejs prototype
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working on a project that is using requirejs, and html. I have an HTML element that has an onclick event:
<li><a href="#" onclick="filesystem.newFloorplan()">New <p class="shortcut">(Ctrl + D)</p></a></li>
When this is clicked, its not working. Here is the main file that is invoking the code:
define(function (require) {
"use strict";
var $ = require('jquery'),
go = require('goJS');
require('bootstrap');
require('jqueryUI');
require('floorWarmingDesignTool-Floorplan');
if ($("#floorWarmingDesignTool").length === 0)
return;
function init()
require(['floorWarmingDesignTool-Floorplan'], function (fp, FloorplanFilesystem)
// Floorplan
var myFloorplan = new fp.Floorplan("myFloorplanDiv");
// Filesystem
var filesyestem = new fp.FloorplanFilesystem(myFloorplan, fp.FILESYSTEM_UI_STATE);
//var ui = new fp.FloorplanUI(myFloorplan, "ui", "myFloorplan", fp.GUI_STATE);
// Palettes - Node Data Arrays
var furniturePalette = new fp.FloorplanPalette("furniturePaletteDiv", myFloorplan, fp.FURNITURE_NODE_DATA_ARRAY);
var wallPartsPalette = new fp.FloorplanPalette("wallPartsPaletteDiv", myFloorplan, fp.WALLPARTS_NODE_DATA_ARRAY);
// Enable Hotkeys
var body = document.getElementById('floorWarmingDesignTool');
body.addEventListener("keydown", function (e)
var keynum = e.which;
if (e.ctrlKey)
e.preventDefault();
switch (keynum)
case 83: filesystem.saveFloorplan(); // ctrl + s
break;
case 79: filesystem.showOpenWindow(); // ctrl + o
break;
case 68: e.preventDefault(); filesystem.newFloorplan(); // ctrl + d
break;
case 82: filesystem.showRemoveWindow(); // ctrl + r
break;
case 49: ui.setBehavior('wallBuilding', myFloorplan); // ctrl + 1
break;
case 50: ui.setBehavior('dragging', myFloorplan); // ctrl + 2
break;
case 72: ui.hideShow('diagramHelpDiv'); // ctrl + h
break;
case 73: ui.hideShow('selectionInfoWindow'); // ctrl + i
break;
case 80: ui.hideShow('myPaletteWindow'); // ctrl + p
break;
case 69: ui.hideShow('myOverviewWindow'); // ctrl + e
break;
case 66: ui.hideShow('optionsWindow'); // ctrl + b
break;
case 71: ui.hideShow('statisticsWindow'); // ctrl + g
break;
);
// Default Model Data
myFloorplan.floorplanFilesystem.loadFloorplanFromModel(fp.DEFAULT_MODEL_DATA);
// See all exposed Floorplan classes
console.log(fp);
);
init();
console.log("Floor Warming Design Tool - Ready!");
);
Here is the snippet of code that is from another module:
define(function (require, exports)
"use strict";
Object.defineProperty(exports, "__esModule",
value: true
);
var $ = require('jquery'),
go = require('goJS');
if ($("#floorWarmingDesignTool").length === 0)
return;
/*
* Instance methods
* New Floorplan, Save Floorplan, Save Floorplan As, Load Floorplan, Remove Floorplan
* Show Open Window, Show Remove Window
* Set Current File Name, Get Current File Name
*/
// Create new floorplan (Ctrl + D or File -> New)
FloorplanFilesystem.prototype.newFloorplan = function ()
var floorplan = this.floorplan;
// checks to see if all changes have been saved
if (floorplan.isModified)
var save = confirm("Would you like to save changes to " + this.getCurrentFileName() + "?");
if (save)
this.saveFloorplan();
this.setCurrentFileName(this.UNSAVED_FILENAME);
// loads an empty diagram
var model = new go.GraphLinksModel;
// initialize all modelData
model.modelData = this.DEFAULT_MODELDATA;
floorplan.model = model;
floorplan.undoManager.isEnabled = true;
floorplan.isModified = false;
if (floorplan.floorplanUI)
floorplan.floorplanUI.updateUI();
floorplan.floorplanUI.updateStatistics();
exports.FloorplanFilesystem = FloorplanFilesystem;
);
How do I get this onclick to work?
Thank You advance-
javascript html requirejs prototype
I am working on a project that is using requirejs, and html. I have an HTML element that has an onclick event:
<li><a href="#" onclick="filesystem.newFloorplan()">New <p class="shortcut">(Ctrl + D)</p></a></li>
When this is clicked, its not working. Here is the main file that is invoking the code:
define(function (require) {
"use strict";
var $ = require('jquery'),
go = require('goJS');
require('bootstrap');
require('jqueryUI');
require('floorWarmingDesignTool-Floorplan');
if ($("#floorWarmingDesignTool").length === 0)
return;
function init()
require(['floorWarmingDesignTool-Floorplan'], function (fp, FloorplanFilesystem)
// Floorplan
var myFloorplan = new fp.Floorplan("myFloorplanDiv");
// Filesystem
var filesyestem = new fp.FloorplanFilesystem(myFloorplan, fp.FILESYSTEM_UI_STATE);
//var ui = new fp.FloorplanUI(myFloorplan, "ui", "myFloorplan", fp.GUI_STATE);
// Palettes - Node Data Arrays
var furniturePalette = new fp.FloorplanPalette("furniturePaletteDiv", myFloorplan, fp.FURNITURE_NODE_DATA_ARRAY);
var wallPartsPalette = new fp.FloorplanPalette("wallPartsPaletteDiv", myFloorplan, fp.WALLPARTS_NODE_DATA_ARRAY);
// Enable Hotkeys
var body = document.getElementById('floorWarmingDesignTool');
body.addEventListener("keydown", function (e)
var keynum = e.which;
if (e.ctrlKey)
e.preventDefault();
switch (keynum)
case 83: filesystem.saveFloorplan(); // ctrl + s
break;
case 79: filesystem.showOpenWindow(); // ctrl + o
break;
case 68: e.preventDefault(); filesystem.newFloorplan(); // ctrl + d
break;
case 82: filesystem.showRemoveWindow(); // ctrl + r
break;
case 49: ui.setBehavior('wallBuilding', myFloorplan); // ctrl + 1
break;
case 50: ui.setBehavior('dragging', myFloorplan); // ctrl + 2
break;
case 72: ui.hideShow('diagramHelpDiv'); // ctrl + h
break;
case 73: ui.hideShow('selectionInfoWindow'); // ctrl + i
break;
case 80: ui.hideShow('myPaletteWindow'); // ctrl + p
break;
case 69: ui.hideShow('myOverviewWindow'); // ctrl + e
break;
case 66: ui.hideShow('optionsWindow'); // ctrl + b
break;
case 71: ui.hideShow('statisticsWindow'); // ctrl + g
break;
);
// Default Model Data
myFloorplan.floorplanFilesystem.loadFloorplanFromModel(fp.DEFAULT_MODEL_DATA);
// See all exposed Floorplan classes
console.log(fp);
);
init();
console.log("Floor Warming Design Tool - Ready!");
);
Here is the snippet of code that is from another module:
define(function (require, exports)
"use strict";
Object.defineProperty(exports, "__esModule",
value: true
);
var $ = require('jquery'),
go = require('goJS');
if ($("#floorWarmingDesignTool").length === 0)
return;
/*
* Instance methods
* New Floorplan, Save Floorplan, Save Floorplan As, Load Floorplan, Remove Floorplan
* Show Open Window, Show Remove Window
* Set Current File Name, Get Current File Name
*/
// Create new floorplan (Ctrl + D or File -> New)
FloorplanFilesystem.prototype.newFloorplan = function ()
var floorplan = this.floorplan;
// checks to see if all changes have been saved
if (floorplan.isModified)
var save = confirm("Would you like to save changes to " + this.getCurrentFileName() + "?");
if (save)
this.saveFloorplan();
this.setCurrentFileName(this.UNSAVED_FILENAME);
// loads an empty diagram
var model = new go.GraphLinksModel;
// initialize all modelData
model.modelData = this.DEFAULT_MODELDATA;
floorplan.model = model;
floorplan.undoManager.isEnabled = true;
floorplan.isModified = false;
if (floorplan.floorplanUI)
floorplan.floorplanUI.updateUI();
floorplan.floorplanUI.updateStatistics();
exports.FloorplanFilesystem = FloorplanFilesystem;
);
How do I get this onclick to work?
Thank You advance-
javascript html requirejs prototype
javascript html requirejs prototype
edited Nov 9 at 21:13
asked Nov 9 at 20:31
Jon Nowak
5419
5419
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
First set the Id of the tag.
Then:
function init()
require(['floorWarmingDesignTool-Floorplan'], function (fp)
var newAnchor = document.getElementById("id");
newAnchor.onclick = function()
fp.filesystem.newFloorplan();
);
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
First set the Id of the tag.
Then:
function init()
require(['floorWarmingDesignTool-Floorplan'], function (fp)
var newAnchor = document.getElementById("id");
newAnchor.onclick = function()
fp.filesystem.newFloorplan();
);
add a comment |
up vote
0
down vote
accepted
First set the Id of the tag.
Then:
function init()
require(['floorWarmingDesignTool-Floorplan'], function (fp)
var newAnchor = document.getElementById("id");
newAnchor.onclick = function()
fp.filesystem.newFloorplan();
);
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
First set the Id of the tag.
Then:
function init()
require(['floorWarmingDesignTool-Floorplan'], function (fp)
var newAnchor = document.getElementById("id");
newAnchor.onclick = function()
fp.filesystem.newFloorplan();
);
First set the Id of the tag.
Then:
function init()
require(['floorWarmingDesignTool-Floorplan'], function (fp)
var newAnchor = document.getElementById("id");
newAnchor.onclick = function()
fp.filesystem.newFloorplan();
);
answered Nov 15 at 14:42
Jon Nowak
5419
5419
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232883%2fhow-to-get-an-onclick-element-to-work-with-requirejs-modules%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown