views:

51

answers:

1

For example, ideally I'd like to go:

newelement = myElement.query('whatever');

Basically how mootools does this:

element = oldemement.getElement('whatever');

What the equivalent in dojo? If it makes a different, I am using this in a drag and drop creator function:

function myCreator( item, hint ) {
    console.log(item);
    var a = dojo.query('.name', item)
    console.log(a);
   var myDiv = dojo.create( 'table', { innerHTML: item.name });
   if (hint == 'avatar') myDiv.innerHTML = 'Im an avator of ' + item.name;
   return {node: myDiv, data: item, type: item.type};
}
dojo.addOnLoad( function() {
    new dojo.dnd.Source("categoryTable", {creator: myCreator });
...

Log of item returns:

 <td><span class="dojoDndHandle">::</span></td>
<td><input type="hidden" name="category_8" value="0"><input type="checkbox" name="category_8" id="category_8" value="1"></td>
<td class="name"><a href="/news/admin/editCategory/8">Category A</a></td>
 <td><span title="18:57:11 04/07/2010">3 days ago</span><br>By <a href="/user/1/">Ashley</a></td>

1 day ago
By Ashley

+1  A: 
dojo.query('whatever', oldelement)

See dojo.query()

kschneid
Doesn't seem to work in my dnd creator function, see edited question for more
Ashley
the second arg to dojo.query is supposed to be an element, it doesn't look like that's what `item` refers to (what is `item`?). also note that dojo.query returns a node list.
kschneid