8000 Cleaned up javascript code by flip111 · Pull Request #4376 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
10BC0
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions reference/forms/types/collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ you need is the JavaScript:
var emailCount = '{{ form.emails|length }}';

jQuery(document).ready(function() {
jQuery('#add-another-email').click(function() {
jQuery('#add-another-email').click(function(e) {
e.preventDefault();

var emailList = jQuery('#email-fields-list');

// grab the prototype template
Expand All @@ -192,9 +194,7 @@ you need is the JavaScript:

// create a new list element and add it to the list
var newLi = jQuery('<li></li>').html(newWidget);
newLi.appendTo(jQuery('#email-fields-list'));

return false;
newLi.appendTo(emailList);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now you removed return false, you should add e.preventDefault() on line 183 and an argument e in the event listener callback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well i'm not sure the default does anything since it's an a href with action #. But i added it anyway ^^

});
})
</script>
Expand Down
0