@@ -353,8 +353,8 @@ will be show next):
353353 var $collectionHolder;
354354
355355 // setup an "add a tag" link
356- var $addTagLink = $ (' <a href="# " class="add_tag_link">Add a tag</a>' );
357- var $newLinkLi = $ (' <li></li>' ).append ($addTagLink );
356+ var $addTagButton = $ (' <button type="button " class="add_tag_link">Add a tag</a>' );
357+ var $newLinkLi = $ (' <li></li>' ).append ($addTagButton );
358358
359359 jQuery (document ).ready (function () {
360360 // Get the ul that holds the collection of tags
@@ -367,10 +367,7 @@ will be show next):
367367 // index when inserting a new item (e.g. 2)
368368 $collectionHolder .data (' index' , $collectionHolder .find (' :input' ).length );
369369
370- $addTagLink .on (' click' , function (e ) {
371- // prevent the link from creating a "#" on the URL
372- e .preventDefault ();
373-
370+ $addTagButton .on (' click' , function (e ) {
374371 // add a new tag form (see next code block)
375372 addTagForm ($collectionHolder, $newLinkLi);
376373 });
@@ -619,7 +616,7 @@ Template Modifications
619616
620617The ``allow_delete `` option means that if an item of a collection
621618isn't sent on submission, the related data is removed from the collection
622- on the server. In order for this to work in an HTML form, you must remove
619+ on the server. In order for this to work in an HTML form, you must remove
623620the DOM element for the collection item to be removed, before submitting
624621the form.
625622
@@ -651,13 +648,10 @@ The ``addTagFormDeleteLink()`` function will look something like this:
651648.. code-block :: javascript
652649
653650 function addTagFormDeleteLink ($tagFormLi ) {
654- var $removeFormA = $ (' <a href="#">delete this tag</a>' );
655- $tagFormLi .append ($removeFormA);
656-
657- $removeFormA .on (' click' , function (e ) {
658- // prevent the link from creating a "#" on the URL
659- e .preventDefault ();
651+ var $removeFormButton = $ (' <button type="button">Delete this tag</a>' );
652+ $tagFormLi .append ($removeFormButton);
660653
654+ $removeFormButton .on (' click' , function (e ) {
661655 // remove the li for the tag form
662656 $tagFormLi .remove ();
663657 });
0 commit comments