Code: Select all
dojo.query( '.square_piece' ).connect( 'onclick', this, 'changePiece' );Code: Select all
dojo.query( '.square_piece' ).disconnect()Thanks
Code: Select all
dojo.query( '.square_piece' ).connect( 'onclick', this, 'changePiece' );Code: Select all
dojo.query( '.square_piece' ).disconnect()Code: Select all
function (dojo, declare) {
return declare("ebg.isaac", ebg.core.gamegui, {
constructor: function(){
console.log('isaac constructor');
// Here, you can init the global variables of your user interface
// Example:
// this.myGlobalValue = 0;
var connections = new Array();
Code: Select all
this.param=new Array();
this.colors= new Array('WHITE','YELLOW','RED','GREEN','BLUE');
connections =new Array();
Code: Select all
// Setup game notifications to handle (see "setupNotifications" method below)
this.setupNotifications();
this.connections = dojo.query('_r_c').map( function( zenode ) { return dojo.connect( zenode, "onclick",this, 'OnClickManagement'); });
dojo.forEach(connections, function(zeconn) { dojo.disconnect(zeconn); });
console.log( "Ending game setup" );
Code: Select all
this.globConnections = dojo.query('piece').map( function( zenode ) { return dojo.connect( zenode, "onclick", this, 'changePiece'); });
Code: Select all
// Array of current dojo connections
this.connections = [];Code: Select all
/**
* Utility to connect and disconnect a single element to/from an event.
*/
connect: function(element, event, handler)
{
if(element == null) return;
this.connections.push({
element: element,
event: event,
handle: dojo.connect(element, event, this, handler)
});
},
disconnect: function( element, event )
{
dojo.forEach(this.connections, function(connection) {
if(connection.element == element && connection.event == event)
dojo.disconnect(connection.handle);
});
},
/**
* Utility to connect an event to all elements of the same css class.
*/
connectClass: function(className, event, handler)
{
var list= dojo.query("."+className);
for(var i=0;i<list.length;i++) {
var element = list[i];
this.connections.push({
element: element,
event: event,
handle: dojo.connect(element, event, this, handler)
});
}
},
/**
* Utility to remove all registered events.
*/
disconnectAll: function()
{
dojo.forEach(this.connections, function(connection) {
dojo.disconnect(connection.handle);
});
this.connections = [];
},Code: Select all
// Add appropriate events
this.connectClass( "uctg_cell", "onclick", "onClickCell");
// Remove all existing events
this.disconnectAll();