Opened 12 years ago
Closed 12 years ago
#6858 closed bug (notabug)
handling for cursor position
Reported by: | g3n3r1c | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.9.0 |
Component: | ui.autocomplete | Version: | 1.8.7 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
We recently got the problem, that IE8 will set cursor position to end in autocomplete input field after click on data item. (UI 1.8.7) and it is not possible to see the begin of text.
So we wrote a function to set cursor position to start after clicked on data item.
new function(jQuery) { jQuery.fn.setCursorPosition = function(pos) { if (jQuery(this).get(0).setSelectionRange) { jQuery(this).get(0).setSelectionRange(pos, pos); } else if (jQuery(this).get(0).createTextRange) { var range = jQuery(this).get(0).createTextRange(); range.collapse(true); range.moveEnd('character', pos); range.moveStart('character', pos); range.select(); } } }(jQuery); to use with autocomplete: select: function(event, ui) { jQuery("pam").val(ui.item.iata); /* IE8 set cursor position to begin when click data item */ jQuery("pam").focus(function() { jQuery(this).setCursorPosition(0); }); }
The problem is: Some need it at the end, some need it at begin.
To Solve: Write an boolean option f.ex. 'cursorToStart: true,' that sets the cursor to begin of input or if false to the end.
jQuery("#acBox").autocomplete({ source : "url/acsearch", minLength: 2, html: true, delay: 1, cursorToStart: true
Change History (2)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
This is not a bug, it's a feature request. We also don't want to support this. Feel free to create an extension for this.
Note: See
TracTickets for help on using
tickets.
It is a opposite of this bug: http://bugs.jqueryui.com/ticket/5761