Javascript Remove a Template Element -
i have template simplify follows:
class="snippet-code-html lang-html prettyprint-override"><script type="text/template" id="contacttemplate"> <div id="contactentry" class="row contact-info"> </div> <div class="form-group"> <label for="name1">first name</label> <input type="text" class="form-control" id="firstname" name="contacts[{{id}}].firstname" required> </div> <div class="form-group minus"> <label for="contactminus{{id}}"> </label> <a id="depminus{{id}}"><i class="fa fa-minus-circle"></i>remove</a> </div> </script>
i allow insertion of template, multiple times via next code, part works:
class="snippet-code-html lang-html prettyprint-override"><script type="text/javascript"> var clone = (function () { var cloneindex = -1; var template = $('#contacttemplate').text(); homecoming function () { //replace instances of {{id}} in our template cloneindex. homecoming template.replace(/{{id}}/g, ++cloneindex); } })();//self executing function. var contacts = $('#contacts') $("#contactadd").on("click", function () { contacts.append(clone()); window.controlmanager.findcontrols(contacts); }); </script> <div id='contacts'> <div class="col col-lg-1"> <a id="contactadd"><i class="fa fa-plus-circle"></i>add</a> </div> </div>
now trying figure out how create javascript code remove each element when/if minus button clicked (in template).
i'm not sure kindof code utilize delete contacts, via depminus{{id}} control. tips me started?
javascript templates
No comments:
Post a Comment