ducksboard / gridster.js

gridster.js is a jQuery plugin that makes building intuitive draggable layouts from elements spanning multiple columns
http://gridster.net/
MIT License
6.04k stars 1.2k forks source link

Stronger validation of configuration #484

Open LazyBui opened 9 years ago

LazyBui commented 9 years ago

I just spent a bunch of time trying to figure out what was going wrong with the library, an error popped up in a spot unrelated to configuration.

Because I had used a regular number for widget_margins (as opposed to an array) and incorrectly assumed that it would utilize this for both dimensions, it was dying with one of the most unhelpful JS errors that could possibly be given (Uncaught TypeError: Cannot read property 'length' of undefined). I had to learn quite a bit about the initialization of the library before I was able to pin it down.

My recommendation would be to strongly validate that the inputs match what the library requires and throw easily-comprehensible errors upon failure to do this.

I realize that the documentation says the specified format, but it would seem to me that there's value in having the code do it as well. Like a typical programmer, I didn't look at the documentation before going off with the example and trying to modify it. :P