mistic100/jQuery-QueryBuilder — pull request #18 by timgws (2014-08-07 07:09:47+00:00)
Title: Ensure data is set when calling setRules

Thanks for all your work so far, Damien.

I am dynamically creating and destroying a QueryBuilder, and as part of that, I am filling in the previous rules. This normally works OK, apart from when I completely empty the rules.

When the rules are completely emptied, and I run something similar to this:

_rules = $('#builder').queryBuilder('getRules');
// do some work with rules... reload a table...
// the rules are empty
$('#builder').queryBuilder('setRules', _rules);

I get an error come up in the Chrome console, and nothing works.

TypeError: Cannot read property 'length' of undefined

This resolves this issue, by checking that the `data` variable is actually defined, and that there are actually some rules to process.