webismymind / editablegrid

EditableGrid is an open source Javascript library aimed at turning HTML tables into advanced editable components. It focuses on simplicity: only a few lines of code are required to get your first table up and running.
http://www.editablegrid.net
Other
795 stars 272 forks source link

Appending rows to empty tables #19

Closed csolar closed 12 years ago

csolar commented 12 years ago

Fixed adding row to an empty table:

when append() is called on an empty table, it invokes insertAfter() passing rowIndex=(data.length-1)=-1. This triggers a call to insert() with rowIndex = 0.

At this point however (rowIndex = data.length) which would trigger a call to insertAfter() with rowIndex=-1 again!

Thus we get stuck in an infinite mutual call between insertAfter() and insert().

I have added a check to make sure we only make a second call to insertAfter if data.length > 0.

webismymind commented 12 years ago

Thanks. I just had to change "legth" into "length".

csolar commented 12 years ago

oops! cheers!