[
https://issues.apache.org/jira/browse/WICKET-4529?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrea Del Bene updated WICKET-4529:
------------------------------------
Attachment: TestScreenshot.png
> 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
> Attachments: TestScreenshot.png
>
>
> 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