views:

32

answers:

0

I have a series of DIV elements that, when clicked on, trigger a DOMWindow open event. No problem there.

Then I had to add keyboard accessibility. DOH!!

I added tabindex attributes to the DIVs, which allows the user to tab from one DIV to the next, and I added a keypress handler to deal with the Enter Key. No problem there.

The problem I AM experiencing is trying to set the focus back to the div that the user was on when he or she hit the Enter Key and opened the DOMWindow (so they can continue tabbing to the next DIV in the series).

I tried adding a function to the "functionCallOnClose" setting of the DOMWindow, but that doesn't appear to do anything.

Here is a code snippet. This is binding the click and keypress events to all DIVs that have a class name of "timeEntry":

$(".timeEntry").live("click keypress", function () {

    // bunch of code here to set up the DOMWindow...

    $.openDOMWindow({

        // bunch of settings here...

        functionCallOnClose: function () {
            // this doesn't work
            // 'DivId' is the object (DIV) that was clicked on
            $(DivId).focus();
        }
    });

});

Does anyone have a clue why I can't seem to get the focus back to the original DIV after the click or keypress events are fired and handled?

I realize this is a pretty obscure question, so I'm throwing it out there in hopes that someone else reading this is using JQuery, DOMWindow, and handling click and keypress events (or at least knows how)

:o)

EDIT: After doing some further debugging, it seems that there is a problem with jQuery getting the tabIndex attribute from DIV tags. When I view the source of my page, I can see the attributes:

<div id="someDiv" class="someClass" tabindex="1"> ... </div>

However, when I try to get the attribute using jQuery, it does not appear to be there.

This code returns "undefined"

var tabindex = $("#someDiv").attr("tabindex");

However, if I set the attribute using jQuery, I can turn around and retrieve it:

// set the tabindex
$("#someDiv").attr("tabindex", "1");

// now this returns "1"
var tabindex = $("#someDiv").attr("tabindex");

Does anyone have a clue why jQuery doesn't return the tabindex attribute when it is set in the HTML, but it will after it is set dynamically using code?

Hope this makes sense...