@@ -353,8 +353,8 @@ will be show next):
353
353
var $collectionHolder;
354
354
355
355
// 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 );
358
358
359
359
jQuery (document ).ready (function () {
360
360
// Get the ul that holds the collection of tags
@@ -367,10 +367,7 @@ will be show next):
367
367
// index when inserting a new item (e.g. 2)
368
368
$collectionHolder .data (' index' , $collectionHolder .find (' :input' ).length );
369
369
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 ) {
374
371
// add a new tag form (see next code block)
375
372
addTagForm ($collectionHolder, $newLinkLi);
376
373
});
@@ -619,7 +616,7 @@ Template Modifications
619
616
620
617
The ``allow_delete `` option means that if an item of a collection
621
618
isn'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
623
620
the DOM element for the collection item to be removed, before submitting
624
621
the form.
625
622
@@ -651,13 +648,10 @@ The ``addTagFormDeleteLink()`` function will look something like this:
651
648
.. code-block :: javascript
652
649
653
650
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);
660
653
654
+ $removeFormButton .on (' click' , function (e ) {
661
655
// remove the li for the tag form
662
656
$tagFormLi .remove ();
663
657
});
0 commit comments