{"action":"created","issue":{"url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/427","repository_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder","labels_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/427/labels{/name}","comments_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/427/comments","events_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/427/events","html_url":"https://github.com/mistic100/jQuery-QueryBuilder/issues/427","id":204591238,"number":427,"title":"setRules/specifying rules not applying value ","user":{"login":"donCarlosOne","id":2841617,"avatar_url":"https://avatars.githubusercontent.com/u/2841617?v=3","gravatar_id":"","url":"https://api.github.com/users/donCarlosOne","html_url":"https://github.com/donCarlosOne","followers_url":"https://api.github.com/users/donCarlosOne/followers","following_url":"https://api.github.com/users/donCarlosOne/following{/other_user}","gists_url":"https://api.github.com/users/donCarlosOne/gists{/gist_id}","starred_url":"https://api.github.com/users/donCarlosOne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donCarlosOne/subscriptions","organizations_url":"https://api.github.com/users/donCarlosOne/orgs","repos_url":"https://api.github.com/users/donCarlosOne/repos","events_url":"https://api.github.com/users/donCarlosOne/events{/privacy}","received_events_url":"https://api.github.com/users/donCarlosOne/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-02-01T14:00:44Z","updated_at":"2017-02-01T14:21:55Z","closed_at":null,"body":"I've encountered an issue creating a new queryBuilder using query-builder.standalone.js and applying existing rules (saved from a user's previous session).  Regardless of how I apply the rules, either during initialization or by explicitly calling setRules after creating the queryBuilder, this fails - and gives a hard error preventing further script execution.\r\n\r\nI've traced the issue to the QueryBuilder.prototype.setRules method.  In line 1695, self.getOperatorByType references model.value - which has not been set yet, causing the reference to it to crash.\r\n\r\nI see that model.value is set AFTER calling self.getOperatorByType, which never gets executed.\r\n\r\nI've worked around this by setting model.value immediately prior to executing self.getOperatorByType, and it works as expected.\r\n\r\n```js\r\nif (model.filter) {\r\n                        model.value = item.value;\r\n                        model.operator = self.getOperatorByType(item.operator, !options.allow_invalid);\r\n\r\n                        if (!model.operator) {\r\n                            model.operator = self.getOperators(model.filter)[0];\r\n                        }\r\n\r\n                        if (model.operator && model.operator.nb_inputs !== 0 && item.value !== undefined)         {\r\n                            model.value = item.value;\r\n                        }\r\n                    }\r\n```"},"comment":{"url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/comments/276668986","html_url":"https://github.com/mistic100/jQuery-QueryBuilder/issues/427#issuecomment-276668986","issue_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/427","id":276668986,"user":{"login":"donCarlosOne","id":2841617,"avatar_url":"https://avatars.githubusercontent.com/u/2841617?v=3","gravatar_id":"","url":"https://api.github.com/users/donCarlosOne","html_url":"https://github.com/donCarlosOne","followers_url":"https://api.github.com/users/donCarlosOne/followers","following_url":"https://api.github.com/users/donCarlosOne/following{/other_user}","gists_url":"https://api.github.com/users/donCarlosOne/gists{/gist_id}","starred_url":"https://api.github.com/users/donCarlosOne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donCarlosOne/subscriptions","organizations_url":"https://api.github.com/users/donCarlosOne/orgs","repos_url":"https://api.github.com/users/donCarlosOne/repos","events_url":"https://api.github.com/users/donCarlosOne/events{/privacy}","received_events_url":"https://api.github.com/users/donCarlosOne/received_events","type":"User","site_admin":false},"created_at":"2017-02-01T14:21:55Z","updated_at":"2017-02-01T14:21:55Z","body":"Didn't mean to close ... hit wrong button"}}
{"actor":{"display_login":"donCarlosOne"}}