INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

[dojo] dom query question

[dojo] dom query question

(OP)
hi bigsmile

I am kind of new to dojo and I have a weird problem using it ...

My goal is to show some search results.

So I build a store, query it and display the results by adding a new div for each result :

CODE --> javascript

var adresseStore;
require([
	         "dojo/dom", 
	         "dojo/store/Memory",	          
	         "dojo/dom-construct",
	         "dojo/query",
..
	     ], 
function(dom, Memory, domConstruct, query){
  ...		
  var container = dom.byId("chefDiv")
  adresseStore = new Memory({data:data, idProperty: "myId"});
  adresseStore.query().forEach(function(item, i){
    addRow(item, container)
    // do something with the index
  }); 
where addRow basically calls

CODE --> javascript

domConstruct.create("div",{...,class: "adresse",...}, container); 

and it works fine thumbsup - i've got something like

CODE --> html

<div id="chefDiv">
  <div class="adresse" ...>...</div>
  <div class="adresse" ...>...</div>
</div> 

Now, I want to open a window when one clicks on an "adresse" div - I add

CODE --> javascript

query(".adresse").on("click", function(){
// do stuff and open a window
} 
and it still works fine 2thumbsup

Great !!! how about adding a button that will hide non valid results ? let's go :
first add a

CODE --> javascript

query(".sltValide").on("click", function(){
  domConstruct.empty("chefDiv");
  adresseStore.query({validite:"V"}).forEach(function(item, i){
    addRow(item, container)
    // stuff with i
  }); // foreach
}); // sltValide 
everything displays well, I still have my

CODE --> html

<div id="chefDiv">
  <div class="adresse" ...>...</div>
  <div class="adresse" ...>...</div>
</div> 
with the data I want to display, I'm happy bigcheeks...


... that is, until I click on a div to open the window ... sadeyes

the

CODE --> javascript

query(".adresse").on("click", function() 
never fires

because

CODE --> javascript

query(".adresse") 
doesn't return anything hairpull

anyone has a clue ? orientalbow
i'm stuck :-/

RE: [dojo] dom query question

(OP)
the answer is to fully qualify the query

CODE

query("#chefDiv").on(".adresse:click", function() {
			    // this works as a charm
}); 
flowerface

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close