Just to add some closure to this traumatic coding problem

I added a simple inline event handler like this


                findTextField = new TextField<String>("query")
                {
                        @Override
                        protected void onComponentTag(ComponentTag tag)
                        {
                                super.onComponentTag(tag);
                                
                                tag.put("onkeypress", "if (event.keyCode == 13) 
{
document.getElementById('" searchSubmitButton.getMarkupId() + "'); return
false;} 
                                
                                // disable browser's autocomplete
                                tag.put("autocomplete", "off");
                        }
                };

This worked a treat in my simplified test page but not in my actual
applications page.  After pulling my hair out for a good couple of hours I
isolated the problem to the fact that I had a Google Map (V3) on the page
which somehow interferes with event handling.  I assume its something to do
with their keyboard controls for moving the map.

After a bit more experimenting I found that I could not cancel the keypress
event as long as the Map was on the page so instead I diverted the form
submit event like this:


                Form<String> searchForm = new Form<String>("search")
                {
                        @Override
                        protected void onComponentTag(ComponentTag tag)
                        {
                                tag.put("onsubmit", "document.getElementById('" 
+
searchSubmitButton.getMarkupId() + "').click(); return false;");
                                super.onComponentTag(tag);
                        }
                };

This works in IE6, Safari and Firefox with a map on the page.  
-- 
View this message in context: 
http://www.nabble.com/Submit-form-with-ajax-on-enter-tp24196732p24216201.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to