views:

40

answers:

1

I have a strange problem, I am trying to implement drag and drop using dojo, this all works fine. However I need to attain the id of all divs with a certain class, I have been unable to do so using the dojo.query method e.g. :

        var totalNumDays = dojo.query(".shiftDropper");
        console.log(totalNumDays.id);

This results is undefined ?

I have also tried using the following:

var totalNumDays = dojo.query(".shiftDropper");
var idName = totalNumDays.attr("id");
console.log(idName);

However this returns the results in a strange way it returns the id's but as an object ? If anyone could point me the right direction it would be great, I will include the HTML source to give u guys a clearer idea of the problem:

        <div id="day1dropper" class="shiftDropper">
            <table class="tableDropTarget" id="day1" dojoType="dojo.dnd.Target" accept="shift" copyOnly="false">
                <tbody></tbody>
            </table>
        <div id="clearButton">Clear Shifts</div>
    </div>

    <div id="day2dropper" class="shiftDropper">
            <table class="tableDropTarget" id="day1" dojoType="dojo.dnd.Target" accept="shift" copyOnly="false">
                <tbody></tbody>
            </table>
        <div id="clearButton">Clear Shifts</div>
    </div>

Thanks in advance

+2  A: 
 var totalNumDays = dojo.query(".shiftDropper")[0];
 console.log(totalNumDays.id);

dojo.query returns an array.

virsir
so does dojo.query(...).attr() ... so: dojo.query(".shoftDropper").attr("id")[0] if you know the first/only element is the one you want.
dante