[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    Re: T4 AutoCompleter onkeypress event never triggered
From:       Paul Stanton <paul.stanton () gunnsoft ! com ! au>
Date:       2008-02-28 22:46:10
Message-ID: 47C739B2.7000301 () gunnsoft ! com ! au
[Download RAW message or body]

Well that works for FireFox, but not IE. in IE the event listener is 
never triggered so I'm assuming it has trouble propagating the event 
handler from the container to the child.

I worked out another solution yesterday though, it's pretty exhaustive 
but it works:

1. this function finds the text field which is dynamically created by 
the AutoCompleter component:
function getTextField()
{
    var elems = document.getElementsByTagName("input");
    for(var i = 0; i < elems.length; i++)
    {
        var elem = elems[i];
        if (elem.type == "text" && elem.className == "dojoComboBox")
            return elem;
    }
    return null;
}

2. this procedure attaches the event handler to it, keep in mind this 
must be called AFTER ALL onload events handlers are finished:
getTextField().onkeypress = function(event)
    {
        if (!event)
            event = window.event;

        if (event.keyCode == 13)
        {
            dojo.event.browser.stopEvent(event);
            return false;
        }
    };

Far from the preferred solution, but it works.

p.

Andreas Andreou wrote:
> I'd connect a key handler somewhere higher at the html hierarchy
> (perhaps at the containing div or form level) and do something like:
>
> dojo.event.connect(dojo.byId('container'), 'onkeydown', function(e) {
>
> if (e.keyCode==13) // or use e.target to refine the condition for ENTER trapping
>    dojo.event.browset.stopEvent(e);
>
>
> } );
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic