On a website of my clients there is a function in Javascript that pressing alt + 5 activates this function:
var chgpgPage = {
goToPrincipal:function(){
window.location.href = 'www.mysite.org';
},
}
The part of the code that triggers the function is this:
: this.AV102pressedSelected.Key == "alt+5"
? chgpgPage.goToPrincipal()
I now need the alt + 4 button to trigger another function that would be this:
require(["dojo", "dijit/form/Button"], function() {
// Invert Button
new dijit.form.Button({
onClick: function() {
dojo.toggleClass(document.documentElement, 'inverted');
}
}, 'invertButton');
});
How would the trigger code look?
: this.AV102pressedSelected.Key == "alt+4"
? ???????????????????
How would you go about triggering the above function? Since it doesn't have var like the other one?
Today the invertButton function is triggered by a button:
<button id="invertButton">Click to Invert</button>
Thank you for your help!
I think you can add a function in chgpgPage like this,
var chgpgPage = {
goToPrincipal:function(){
window.location.href = 'www.mysite.org';
},
invert:function(){
require(["dojo", "dijit/form/Button"], function() {
ojo.toggleClass(document.documentElement, 'inverted');
});
}
}
invert function will have the logic to invert. And you will trigger this function as:
: this.AV102pressedSelected.Key == "alt+4"
? chgpgPage.invert()