Skip to content

Removed 'return false' in favor of preventDefault. #24

merged 1 commit into from May 18, 2012

7 participants


Using 'return false' makes it very difficult to add additional event handlers to the add button because it prevent the events from bubbling up; preventDefault appears to be the desired behavior.

Also, other various js fixes like === instead of ==, missing parseInt radix, and missing semi colons

Django member

Hey, this is looking good. I have one question, though -- should the preventDefault calls perhaps be at the start of the event handler instead of the end? That way, if there's a runtime error in the handler, the link won't get followed (even though its href is "#").

See the Stack Overflow answer by Jeff Poulton here for a better explanation:

Worth changing?


Good idea


Note that internet explorer 8- doesn't support preventDefault. So you probably want to do this instead:

if (e.preventDefault) { 
} else {
    e.returnValue = false;
mlavin commented May 9, 2012

IE doesn't natively support e.preventDefault but this is will work inside a jQuery event handler because jQuery.Event defines preventDefault

Django member
alex commented May 10, 2012

Looks good to me, Adrian, are you good with this?

Django member

This looks good -- thanks, guys. I'd like us to start squashing our pull requests, though, so that I end up making only one commit to the Django master repository. @marcneuwirth -- can you squash your commits into one?

@adrianholovaty adrianholovaty merged commit 04785d2 into django:master May 18, 2012
Django member

Thank you!

Django member
jezdez commented May 19, 2012

The minified version needs to be updated, too.

Django member
jphalip commented Jun 16, 2012

The minified version was updated in fadcc6d.

Django member
jezdez commented Jun 17, 2012

Odd, pretty sure I updated the files, at the time, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.