Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I could fix it for now. As long as an input field is not attached to the dom you can change the name and the radio buttons work properly again.</p> <pre><code>// Old Code $("div:last").clone(true).children("input").attr("name","newName"); // New Code $("div:last").clone(true).children("input").fixCloneBug ("newName"); </code></pre> <p>To lower the execution time only the jQuery Events, the className and the type attribute are copied.</p> <p>fixCloneBug Method:</p> <pre><code>(function( $ ) { if ( ! $.browser.msie || parseInt( $.browser.version ) &gt; 7 ) // NO FIX FOR IE 7+ FF WEBKIT $.fn.fixCloneBug = function( newName ){ return this.attr( "name", newName ) }; else // FIX IE 5-7 $.fn.fixCloneBug = function( newName ) { var $cloned = $(); this.each(function( ) { /* -._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._ Create a new element with className and jQuery events of the buggy element */ var $elem = $(this), $newElem = $(document.createElement( $elem.attr('tagName') )); // USE SAME TYPE $newElem.attr('type', $elem.attr('type') ); // SET NAME $newElem.attr('name', this.name ); $newElem.attr('name', newName ); // ADD TO DOM $newElem.insertBefore( $elem ); // CLONE EVENTS $newElem.data( "events", $elem.data("events") ); // CLASS NAME $newElem.attr('className', this.className ); /* -._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._ Delete buggy element */ $elem.remove(); // Add to result $cloned.push($newElem); }) return $cloned; } }(jQuery)); </code></pre> <p>Maybe you think <code>$newElem.attr('name', this.name );</code> is useless however it allows me to use a jQuery 1.4 feature:</p> <p><code>.fixCloneBug (function(i,oldname){ return oldname+"_new" })</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload