[ https://issues.apache.org/jira/browse/WICKET-4529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13269682#comment-13269682 ]
Martin Grigorov commented on WICKET-4529: ----------------------------------------- I just tried document.getElementsByName("text")[0].select() at http://www.wicket-library.com/wicket-examples/compref/wicket/bookmarkable/org.apache.wicket.examples.compref.TextFieldPage and it works on IE9, Opera 11.61, Safari 5.1.5 and Chrome 18.x (Win7) and 20.x (Ubuntu). It doesn't work on Firefox 11 (both Win7 and Ubuntu). > AjaxEditableLabel not selecting text or moving cursor on Firefox 11.0 or > Safari 5.0.5 > ------------------------------------------------------------------------------------- > > Key: WICKET-4529 > URL: https://issues.apache.org/jira/browse/WICKET-4529 > Project: Wicket > Issue Type: Bug > Components: wicket-extensions > Affects Versions: 1.5.5 > Environment: MacOS > Reporter: Erwin Bolwidt > > The class Javadoc for AjaxEditableLabel says: > """ > onEdit(AjaxRequestTarget) is called when the label is clicked and the editor > is to be displayed. The default implementation switches the label for the > editor and places the caret at the end of the text.</li> > """ > However this does not happen on Firefox or Safari. > Looking at the code, it is actually trying to place the caret at the end of > the line _and_ selecting the text in the form field. (This -selecting the > text- is what I also want, and also the most common behavior of such > ajax-editable fields on other big websites on the Internet) > // put focus on the textfield and stupid explorer hack to move the > // caret to the end > target.appendJavaScript("{ var el=wicketGet('" + editor.getMarkupId() + "');" > + > " if (el.createTextRange) { " + > " var v = el.value; var r = el.createTextRange(); " + > " r.moveStart('character', v.length); r.select(); } }"); > target.focusComponent(editor); > However the "stupid explorer hack" as the code calls it, probably _only_ > works on explorer, because the el.createTextRange method is quite old and > deprecated (it's only needed on MSIE <9) > I'm getting good results by just calling select() on the DOM element. I don't > have MSIE available to test there but I think it will work there too. > // put focus on the textfield and stupid explorer hack to move the > // caret to the end > target.appendJavaScript("{ var el=wicketGet('" + editor.getMarkupId() + "');" > + > " el.select(); " + > " }"); > target.focusComponent(editor); -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira