#8679 closed bug (patchwelcome)
Jquery live with select method problem in internet explorer
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | selector | Version: | 1.5.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I want to use jquery live() to automatically select the text in a text box but it doesn't seem to work in internet explorer 8. Here's the code:
<!DOCTYPE html PUBLIC "-W3CDTD HTML 4.01 TransitionalEN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script> <script type="text/javascript"> $(function(){
$('input.textInput') .live('focus',
function(e){
$(this).select(); alert(1) if i uncomment this it works
});
}); </script>
</head> <body> <input type="text" class="textInput" value="0,00" /> </body> </html>
If, however, i uncomment the "alert(1)" statement it does work. Any ideas what the problem is here?
Change History (4)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → selector |
---|---|
Priority: | undecided → low |
Resolution: | → patchwelcome |
Status: | new → closed |
Thanks for submitting a ticket to the jQuery Bug Project.As per timmywil's suggested workaround, you can easily use setTimeout to avoid the issue you're experiencing with IE8. Unless we find that a significant number of other users are also running into the same problem attempting such behavior using live with IE, we'll be closing this ticket as patch-welcome for now.
You can do this instead: http://jsfiddle.net/timmywil/m9Pyu/1/ The setTimeout with a time of 0 places the .select at the bottom of the stack, allowing you to select after IE runs it's code to focus on the input.