[ 
https://issues.apache.org/jira/browse/WICKET-4529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13274261#comment-13274261
 ] 

Andrea Del Bene commented on WICKET-4529:
-----------------------------------------

@Martin

 select() should work also for Firefox. How did you test your JavaScript code 
(with firebug console?)?. I've changed code as suggested by Erwin and tested it 
with example /wicket-examples/ajax/editable-label. Everything was fine with the 
following configurations:

-Firefox 12 under Ubuntu
-Chromium 18 under Ubuntu
-Firefox 11 and 12 under Windows xp
-Opera 11.64 under Windows xp
-Safari 5.1.7 under Windows xp
-IE 7 and 8 under Windows xp

                
> 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

        

Reply via email to