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

change on* events to addEventListener #9

Closed simonzack closed 11 years ago

simonzack commented 13 years ago

Hi,

Is it possible to change the onclick, onblur, and other events to addEventListener? I use this for greasemonkey, which does not support setting on* due to xpcnativewrapper

thanks, love the lib

webismymind commented 13 years ago

Hello,

Yes this would definitely be an improvement. I will take care of this soon, but I you do it before, don't hesitate to share ;)

simonzack commented 13 years ago

Hi,

I'm doing this right now for version 1.0.10 :p seems like 1.0.11 is nearly ready for release, I'll post the changes once I get it all working

webismymind commented 13 years ago

Thanks!

BTW, 1.0.11 is already released (available in the downloads). I had forgotten to push the tags, I just did it.

simonzack commented 13 years ago

I've updated the code so it uses eventListeners for v1.0.11 something I also noticed is some custom dom properties are set for elements, say .isEditable, which greasemonkey doesn't support changed this to setAttribute to make demo.js work you'll need to change "cell.rowIndex" to "cell.parentNode.rowIndex - editableGrid.nbHeaderRows" on line 115 makes things a bit more complicated, but compatible with dom :)

http://www.mediafire.com/?0k4m99litw3tm1q

hope you accept the changes

webismymind commented 13 years ago

Hello,

Thank you!

Il had a look at the proposed changes. While I agree on both ideas (use event listeners and avoid custom dom properties to make it compatible with Greasemonkey), I'll need some time before merging the changes, in order to find a clean solution to keep this compatible.

We indeed have a lot of code in production that is using EditableGrid and which I do not want to change, and the same for other users of the library. A library must stay backward compatible when possible, or users will not be happy ;)

I am thinking of an advanced config option "useCustomDomProperties" which would be true by default to ensure backward compatibility. If useCustomDomProperties is set to false (as in your case) you would have to replace "cell.rowIndex" with "cell.getAttribute('rowIndex')". Will take care of this ASAP.

I am reopening the issue until this is done.

webismymind commented 13 years ago

Hi,

Since I'm quite busy for the moment, I created a branch "smk64" with your changes. I will merge this branch in the master branch asap, doing the needed changes to keep compatibility with existing code.