{"action":"created","issue":{"url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/394","repository_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder","labels_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/394/labels{/name}","comments_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/394/comments","events_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/394/events","html_url":"https://github.com/mistic100/jQuery-QueryBuilder/issues/394","id":190093678,"number":394,"title":"Use events with setRules","user":{"login":"nikataus","id":19806909,"avatar_url":"https://avatars.githubusercontent.com/u/19806909?v=3","gravatar_id":"","url":"https://api.github.com/users/nikataus","html_url":"https://github.com/nikataus","followers_url":"https://api.github.com/users/nikataus/followers","following_url":"https://api.github.com/users/nikataus/following{/other_user}","gists_url":"https://api.github.com/users/nikataus/gists{/gist_id}","starred_url":"https://api.github.com/users/nikataus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikataus/subscriptions","organizations_url":"https://api.github.com/users/nikataus/orgs","repos_url":"https://api.github.com/users/nikataus/repos","events_url":"https://api.github.com/users/nikataus/events{/privacy}","received_events_url":"https://api.github.com/users/nikataus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-17T16:22:04Z","updated_at":"2016-11-17T16:49:46Z","closed_at":null,"body":"Hi,\r\n\r\nI have 2 filters for States and Counties and implemented logic when the user adds County rule to build relation with State Rule and implement onchange event to populate the county list based on State selected... \r\nI used the Event system so when the County rule has been created I add my logic or something like:\r\n$('#adhocBuilder').on('afterCreateRuleInput.queryBuilder', function(e, rule) {\r\n\r\n\t\tvar $container = rule.$el.find('.rule-filter-container');\r\n\t \tvar countyRule =  $container.find('[name='+ rule.id +'_filter]');\r\n.......\r\nstateValueControl.on(\"change\", (function(){\r\n\r\n\t\t\t\tvar selectedStateCode = $(this).val();\r\n   \t\t \t\tcountyValueControl.empty();\r\n\t   \t\t\t\t\r\n   \t\t\t\t$.each( statesToCountyMap[selectedStateCode], function( key, item ) {\r\n   \t\t\t\t\tcountyValueControl.append($('<option>', {\r\n   \t\t\t\t        value: key,\r\n   \t\t\t\t        text : item\r\n   \t\t\t\t\t}));\r\n   \t\t\t\t\t\r\n   \t\t\t\t });\r\n\t\t \t}));\r\n..............\r\n\r\nHere is my issue now: \r\nI'm using predefined set of rules and I have user profiles to pre define Rules when the User opens the QueryBuilder page. In other words when I initialize QueryBuilder I call at the end\r\n\t  \t$('#adhocBuilder').queryBuilder('setRules', rules);\r\nWhen I do this I can NOT use anymore the events and I can NOT build state to county relationship.\r\nCan you please let me know when I use setRules method how can I catch when the Rule has been created, so I can add my logic there?\r\n\r\nThanks in advance!\r\nNick\r\n"},"comment":{"url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/comments/261301106","html_url":"https://github.com/mistic100/jQuery-QueryBuilder/issues/394#issuecomment-261301106","issue_url":"https://api.github.com/repos/mistic100/jQuery-QueryBuilder/issues/394","id":261301106,"user":{"login":"nikataus","id":19806909,"avatar_url":"https://avatars.githubusercontent.com/u/19806909?v=3","gravatar_id":"","url":"https://api.github.com/users/nikataus","html_url":"https://github.com/nikataus","followers_url":"https://api.github.com/users/nikataus/followers","following_url":"https://api.github.com/users/nikataus/following{/other_user}","gists_url":"https://api.github.com/users/nikataus/gists{/gist_id}","starred_url":"https://api.github.com/users/nikataus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikataus/subscriptions","organizations_url":"https://api.github.com/users/nikataus/orgs","repos_url":"https://api.github.com/users/nikataus/repos","events_url":"https://api.github.com/users/nikataus/events{/privacy}","received_events_url":"https://api.github.com/users/nikataus/received_events","type":"User","site_admin":false},"created_at":"2016-11-17T16:49:46Z","updated_at":"2016-11-17T16:49:46Z","body":"Well, When I call setRules, the 'afterCreateRuleInput.queryBuilder' is not called at all! That's my issue...\r\nWhen I click AddRule button and add County Rule then 'afterCreateRuleInput.queryBuilder' is called and everything works fine.\r\nIs that expected or I'm not doing something right?"}}
{"actor":{"display_login":"nikataus"}}