Page 1 of 1

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

Posted: 12 May 2013, 21:53
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_*')?

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

Posted: 12 May 2013, 22:04
by Rudolf
I solved this by replacing only by '*' ... but I would like to kno how i can prefix ;)

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

Posted: 18 August 2015, 22:51
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')

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

Posted: 24 August 2015, 09:22
by Rudolf
Hello,
thanks Quinarbre, but you answer to a post of two years ago :)