jlord / hack-spots

Using Sheetsee.js and power of collaboration to collect the best places to get your hack on.
jlord.github.io/hack-spots
Other
157 stars 241 forks source link

Table isn't sortable, throws Uncaught ReferenceError: gData is not defined #21

Closed deltamualpha closed 9 years ago

deltamualpha commented 9 years ago

So in playing around with this for my own project, I realized the table sort was broken because the function that handled that couldn't find gData. Some investigation (I'm no javascript pro) lead me to fix this by changing line 132 in index.html to window.gData = gData, 'hoisting' the variable into the global namespace. No idea if this is how you want to solve it, but I wanted to try and be a little more helpful than "it doesn't work".

jlord commented 9 years ago

Ah, that's bad. I'm afraid this whole thing should be re-written, I get really terrified when I look at it now :flushed:

I think that's a fine fix for this right now, if you want to do a PR that would be :sparkles:

deltamualpha commented 9 years ago

OK! I'll see what I can do (my main branch has diverged far enough that I can't just pull out the commit, I think).

Heck, this might be a fun project to learn me some proper JS and try a cleanup/modernization pull request...

jlord commented 9 years ago

So I actually just put in the latest version and sheetsee.js (this project had a really old version) and it solved the issue you were having. I'm going to go ahead and push it, but there is still lots of clean up that could be done!

jlord commented 9 years ago

Ok, I spoke too soon :) I ended up breaking more things than I fixed, so let's go with your way for now!

deltamualpha commented 9 years ago

Pull request done for that small change.

I'm seeing what you meant by the difficulty in upgrading sheetsee! I'm currently fighting with iCanHaz not having the templates available within the table() function... it's mystifying.

Update: initial work here: https://github.com/nyc-bookstores/nyc-bookstores.github.io/tree/sheetsee-upgrade. Getting strange errors when clicking on items on the map, and the popups don't render anymore. Also, I found a bug in sheetsee-table (the if-else logic on non-paginated tables is busted, causing it to render the table twice, the second time with no data, resulting in an empty table.)

deltamualpha commented 9 years ago

For the makeTable() bug, compare https://github.com/jlord/sheetsee.js/blob/master/js/sheetsee.js#L25273-L25282 with https://github.com/nyc-bookstores/nyc-bookstores.github.io/blob/62d257957b73d42bd008ca89d66035f22bcc74b5/js/sheetsee.js#L16171-L16182