IE and replaceWith not preserving radio button state

Posted by copelco on Stack Overflow See other posts from Stack Overflow or by copelco
Published on 2010-05-04T17:35:08Z Indexed on 2010/05/04 17:38 UTC
Read the original article Hit count: 195

Filed under:
|

Hello,

I've run into an issue regarding replaceWith not maintaining the state of a moved radio button input. I've prepared a simple example illustrating this issue. This works in FF and Chrome, but not IE.

Is there a way around this?

Thanks!

jsbin: http://jsbin.com/unola4/2

code:

<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<title>IE replaceWith issue</title>
<script type='text/javascript'>
$(function(){
  $('a').click(function(e) {
    e.preventDefault();
    $('#temp').replaceWith($('#window').children());
  });
});
</script>
</head>
<body>
  <a href='#'>run replaceWith</a>
  <p>Select a radio button and then click "run replaceWith". The value persists in FF, but not IE.</p>
  <div id='window' style='background-color: #DDD; height: 100px;'>
    <input id="id_received_date-days_0" type="radio" name="received_date-days" value="30" />
    <input id="id_received_date-days_1" type="radio" name="received_date-days" value="50" />
    <input type='text' name='test-test' />
  </div>
  <br />
  <form id='foo' style='background-color: #EEE'>
    <div id='temp'></div>
  </form>
</body>
</html>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript