Skip to content

Commit

Permalink
minor #4376 Cleaned up javascript code (flip111)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wouterj committed Oct 26, 2014
2 parents 06e7c5f + 8931249 commit 3e8aa59
Showing 1 changed file with 4 additions and 4 deletions.
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);
});
})
</script>
Expand Down

0 comments on commit 3e8aa59

Please sign in to comment.