JQuery - I can't clone my form events -


i'm trying clone form events cant, created script tags, , working that:

print 1

and created script duplicate form, i'm using jquery clone(), , when click @ duplicate link, duplicates form not events, resuming, script created write tags works first form, doesn't work cloned forms

print 2

here tags text fields

<label>tags<a class="required_field">*</a></label> <div id="wrapbox"> <div id="box"> <span id="checktags"></span> <input type="text" class="to-be-clicked" id="tags"  maxlength="230"> </div> </div> 

the code scripts, created hidden textbox inside script

   $('#tags').keypress(function(e) { //check if space clicked, , create new tag        if(e.which == 32) {            var tx = $('#tags').val();            if (tx) {             $(this).val('').parent().before('<li class="tags"><span><input type="hidden" value="'+tx+'" name="tags[]" />'+tx+'</span><a style="cursor:pointer;" id="close">[x]</a></li>');                closer();            }        }    }); 

and clone() function

$(function(){      var template = $('#jb').clone();       var offerscount = 1;      window.addoffer = function(){          offerscount++;          var offer = template.clone().find(':input').each(function(){              var newid = this.id.substring(0, this.id.length-1) + offerscount;               this.name = this.id = newid; // update id , name (assume same)          }).end()         .attr('id', 'att' + offerscount)         .prependto('#jb');     }     $('.add').click(addoffer); }); }); 

you need set withdataandevents arguement true in clone() clone events well: .clone(true);

as mentioned on docs, argument default false , is:

"a boolean indicating whether event handlers should copied along elements. of jquery 1.4, element data copied well."


Comments

Popular posts from this blog

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -

c# - MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(3243,9): error MSB4094 -