felito Posted December 13, 2011 Share Posted December 13, 2011 I have this code, but when I clone an element, then the action is also cloned. What i want is just individual actions for each element.You can see the problem in demo <script type="text/javascript"> $(document).ready(function() { $('.edit').editable('http://save.php', { indicator : 'Saving...', submit : 'OK', cancel : 'Cancelar', }); }); $(document).ready(function () { $('#btnAdd').live('click', function(){ var num = $('.clonedInput').length; var newNum = new Number(num + 1); var newElem = $('#input' + num).clone(true).prop('id', 'input' + newNum); newElem.children(':text').prop('name', "myformdata[job][]").prop('job', 'job').val(''); $('#input' + num).after(newElem); $('#btnDel').prop('disabled', ''); if (newNum == 4) $('#btnAdd').prop('disabled', 'disabled'); }); $('#btnDel').live('click', function(){ var num = $('.clonedInput').length; $('#input' + num).remove(); $('#btnAdd').prop('disabled', ''); if (num - 1 == 1) $('#btnDel').prop('disabled', 'disabled'); }); $('#btnDel').prop('disabled', 'disabled'); }); </script> <div class="clonedInput" id="input1"> <span style="float: left;">job</span> <div class="edit" id="job="myformdata[job][]">Job</div> </div> <div id="copy"> <input class="format" type="button" id="btnAdd" value="Ad" /> <input class="format" type="button" id="btnDel" value="Re" /> </div> http://jsbin.com/unebex/8/edit#preview Link to comment https://forums.phpfreaks.com/topic/253050-stop-propagation-jquery/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.