diefenbach / django-lfs

An online-shop based on Django
http://www.getlfs.com
BSD 3-Clause "New" or "Revised" License
622 stars 222 forks source link

Manage: TypeError: e is undefined #198

Closed jzuschlag closed 9 years ago

jzuschlag commented 9 years ago

well, e is never assigned, that's obvious:

input class="refresh-on-keyup" type="text" value="" onkeypress="return disable_enter_key()" style="width:100%" name="name"

but:

function disable_enter_key(e) { var key; if (window.event) key = window.event.keyCode; else key = e.which; if (key == 13) return false; else return true; }

Test: Open products in management, open a Firebug console, enter just one letter in search field.

Doesn't seem to do any bad so far.

pigletto commented 9 years ago

This is fixed in 0.9+

jzuschlag commented 9 years ago

You are right. I had some difficulties to find the commit since there is a break in history in Github. But why do we keep "e" in the java code? Is there another use case? I couldn't find one, but I am not so familiar with manage.

pigletto commented 9 years ago

e stands for event that is passed to disable_enter_key function which acts as keypress event handler here: https://github.com/diefenbach/django-lfs/blob/master/lfs/manage/static/lfs/js/lfs.manage.js#L553

Have a look at: https://api.jquery.com/keypress/ for documentation. window.event is old style used by IE < 9

jzuschlag commented 9 years ago

Yeah, I just found the added event handler. Thanks anyway. So you will remove the old style sooner or later.