8000 minor #4376 Cleaned up javascript code (flip111) · symfony/symfony-docs@3e8aa59 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e8aa59

Browse files
committed
minor #4376 Cleaned up javascript code (flip111)
This PR was squashed before being merged into the 2.3 branch (closes #4376). Discussion ---------- Cleaned up javascript code | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.3 | Fixed tickets | n/a 1. Reused variable `emailList` which is best practice and easier to read 2. Removed `return false`. There is no use for it in this context and many consider it to be bad use as well. For example: http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/ Commits ------- 8931249 Cleaned up javascript code
2 parents 06e7c5f + 8931249 commit 3e8aa59

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

reference/forms/types/collection.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ you need is the JavaScript:
179179
var emailCount = '{{ form.emails|length }}';
180180

181181
jQuery(document).ready(function() {
182-
jQuery('#add-another-email').click(function() {
182+
jQuery('#add-another-email').click(function(e) {
183+
e.preventDefault();
184+
183185
var emailList = jQuery('#email-fields-list');
184186

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

193195
// create a new list element and add it to the list
194196
var newLi = jQuery('<li></li>').html(newWidget);
195-
newLi.appendTo(jQuery('#email-fields-list'));
196-
197-
return false;
197+
newLi.appendTo(emailList);
198198
});
199199
})
200200
</script>

0 commit comments

Comments
 (0)
0