Friday, July 31, 2009

[jQuery] Re: Does IE support live?

hi David, you have to bind "jump" in load callback function.

 $(function() {
       $.ajaxSetup({
               cache: false
       });

       $('#btn').click(function() {
               $('div:first').load('b.html',function(){loadCallback();});
       });

      
});


function  loadCallback()
{
      $('#jump').live('change', function() {
               alert(1);
       });
}

I think this will fulfill your requirement .

On Fri, Jul 31, 2009 at 12:28 PM, David .Wu <chan15tw@gmail.com> wrote:

If I load b.html in firefox, alert(1) will work, but ont work in IE.

page a.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>live</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
</head>

<body>
<div style="width: 300px; height: 300px; border: 1px solid red;"></
div>
<input type="button" id="btn" value="btn" />
<script>
$(function() {
       $.ajaxSetup({
               cache: false
       });

       $('#btn').click(function() {
               $('div:first').load('b.html');
       });

       $('#jump').live('change', function() {
               alert(1);
       });
});
</script>
</body>
</html>

page b.html
<select id="jump">
       <option value="1">1</option>
   <option value="2">2</option>
</select>

No comments: