Permalink
Browse files

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
  • Loading branch information...
wouterj committed Oct 26, 2014
2 parents 06e7c5f + 8931249 commit 3e8aa59ba74ac1b1ec5938de8370bf449e3790dc
Showing with 4 additions and 4 deletions.
  1. +4 −4 reference/forms/types/collection.rst
@@ -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
@@ -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>

0 comments on commit 3e8aa59

Please sign in to comment.