jQuery and the stray firearms list

by Patrick Cain

Our list of misclassified handguns and automatic weapons likely to be deleted along with the long gun registry is now at 406.

The story lends itself very well to a jQuery data table, an embeddable, searchable, sortable sort of spreadsheet I’ve been wanting to use since seeing it demonstrated at the NICAR conference. There was, as always, a learning curve - troubleshooting interactive tools on deadline (while also trying to report a story conventionally) isn’t anybody’s favourite experience, certainly not mine, but it worked out in the end.

- The first had to do with a quirk of the code in which the last item in the table must not end in a comma, as all the others do. Neglecting this breaks the table in a way that is only visible in IE - in other words, if you tested the thing in Firefox or Chrome at a low-stress point in the day, and didn’t see a problem then, there’s potential for a nasty surprise down the road at a high-stress point of the day. (NICAR-L was helpful solving this problem, I think within 15 minutes.)

- The second had to do with figuring out how to massage the complete table below 920px/w for display in our CMS. This turned out to be a problem with a very low-tech solution - column width is determined by the longest continuous string of characters in the column. A few instances of HARRINGTON&RICHARDSON instead of HARRINGTON & RICHARDSON will push a complex table too far out to the right. The solution, which does not really seem like a digital-age thing, involves holding a straight-edge (a pencil will do) up to the end of the line and scanning down for the long string that breaks the table. This looks ridiculous but works, like some other things.