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

merged 1 commit into from May 18, 2012


None yet

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


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

alex commented May 10, 2012

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


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

Thank you!

jezdez commented May 19, 2012

The minified version needs to be updated, too.

jphalip commented Jun 16, 2012

The minified version was updated in fadcc6d.

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