Version 1.7Removing Event Listeners
API Quick Reference
JavaScript is required to use the quick reference
Overview
Using the glow.events.removeListener method it is possible to remove event listeners that you have created with the glow.events.addListener
method.
Below is a simple example of how to use the removeListener method. The button has no code applied to it by default, however clicked on the checkbox will give the button a JavaScript alert box:
HTML
<input type="checkbox" id="listener_switch" />
<label for="listener_switch">Alert on/off</label>
<input type="button" id="listener_target" value="ALERT" />
JavaScript
// This variable stores the event listener
var alert_listener;
// Add an event listener onto the radio box to listen for clicks
glow.events.addListener("input#listener_switch", "click", function(event) {
// If the check box is checked then add the event listener onto the button
if(this.checked) {
alert_listener = glow.events.addListener("input#listener_target", "click", function() {
alert("ALERT");
});
// Else remove the event listener from the button
} else {
glow.events.removeListener(alert_listener);
}
});