Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#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 Timmy Willison

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.

comment:2 Changed 12 years ago by addyosmani

Component: unfiledselector
Priority: undecidedlow
Resolution: patchwelcome
Status: newclosed

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.

Version 0, edited 12 years ago by addyosmani (next)

comment:3 Changed 12 years ago by anonymous

Many thanks for the work around!

comment:4 Changed 12 years ago by Timmy Willison

#9871 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.