search for good divs (for disconnect all) ...

Game development with Board Game Arena Studio
Post Reply
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

search for good divs (for disconnect all) ...

Post by Rudolf »

Hello
well, i add a query to disconnect my nodes, but it seems not to find my nodes!
the second message is not displayed.
OnEnteringState:

Code: Select all

case 'PlayPipe':
								    	if (this.isCurrentPlayerActive())
									{
									   for ( var id in this.gamedatas.plaincards )
				    					   {
										var card = this.gamedatas.plaincards[id];
										var r = card.plain_row;
										var c = card.plain_col;
										var i =	card.plain_card;		
										var s = card.plain_status;
										if ((i>0) && (i<5)) // Hunter
										{	
											var node=$("p_"+r+'_'+c);
											node.connectionclick=[];
											node.connectionover=[];
											node.connectionout=[];
											
											dojo.style(node,"border","4px solid #FF0000");
											node.connectionover.push(
												dojo.connect(node, "onmouseover", 
													function(evt){ 
														dojo.stopEvent(evt); 
														dojo.style(evt.target.id,"border","4px solid #FFFFFF");}));
											node.connectionout.push(
												dojo.connect(node, "onmouseout", 
													function(evt){ 
														dojo.stopEvent(evt); 
														dojo.style(evt.target.id,"border","4px solid #FF0000");}));
								            		node.connectionclick.push(
												dojo.connect($("p_"+r+'_'+c),'onclick',this, 'OnClickManagement'));
										}
									   };
									}
OnLeavingState

Code: Select all

case 'PlayPipe':
								if (this.isCurrentPlayerActive())
								{	this.showMessage('leavePlaypipe','info');
									dojo.query("p_*", $('board')).forEach(function(node)
									{
										this.showMessage('disconnect Plain hunter','info');
										dojo.style(node,"border","2px solid #8B4513"); 
    										if (typeof node.connectionclick!="undefined")
										{
											
        										dojo.forEach(node.connectionclick, "dojo.disconnect(item)");
											dojo.forEach(node.connectionover, "dojo.disconnect(item)");
											dojo.forEach(node.connectionout, "dojo.disconnect(item)");
    										};
									});
								};
								break;
it's not possible to query like that ('p_*')?
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: search for good divs (for disconnect all) ...

Post by Rudolf »

I solved this by replacing only by '*' ... but I would like to kno how i can prefix ;)
User avatar
Quinarbre
Posts: 140
Joined: 15 December 2013, 23:26

Re: search for good divs (for disconnect all) ...

Post by Quinarbre »

I think you mean

Code: Select all

dojo.query("#p_*", $('board'))
Don't forget that query's first argument is a CSS selector, not a regexp for an id.
I don't even think that will work, the star wildcard is not supposed to replace part of a class or an id.

You'd better give a common class, say "pclass", to all of your p_* divs, and then use

Code: Select all

dojo.query('.pclass')
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: search for good divs (for disconnect all) ...

Post by Rudolf »

Hello,
thanks Quinarbre, but you answer to a post of two years ago :)
Post Reply

Return to “Developers”