{"action":"created","issue":{"url":"https://api.github.com/repos/Availity/availity-angular/issues/46","labels_url":"https://api.github.com/repos/Availity/availity-angular/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/Availity/availity-angular/issues/46/comments","events_url":"https://api.github.com/repos/Availity/availity-angular/issues/46/events","html_url":"https://github.com/Availity/availity-angular/pull/46","id":82123300,"number":46,"title":"Added documentation for remote dropdown. Select2 fixes.","user":{"login":"JamieCrisman","id":697955,"avatar_url":"https://avatars.githubusercontent.com/u/697955?v=3","gravatar_id":"","url":"https://api.github.com/users/JamieCrisman","html_url":"https://github.com/JamieCrisman","followers_url":"https://api.github.com/users/JamieCrisman/followers","following_url":"https://api.github.com/users/JamieCrisman/following{/other_user}","gists_url":"https://api.github.com/users/JamieCrisman/gists{/gist_id}","starred_url":"https://api.github.com/users/JamieCrisman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JamieCrisman/subscriptions","organizations_url":"https://api.github.com/users/JamieCrisman/orgs","repos_url":"https://api.github.com/users/JamieCrisman/repos","events_url":"https://api.github.com/users/JamieCrisman/events{/privacy}","received_events_url":"https://api.github.com/users/JamieCrisman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-28T21:02:33Z","updated_at":"2015-06-11T03:00:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Availity/availity-angular/pulls/46","html_url":"https://github.com/Availity/availity-angular/pull/46","diff_url":"https://github.com/Availity/availity-angular/pull/46.diff","patch_url":"https://github.com/Availity/availity-angular/pull/46.patch"},"body":"Select2's remote dropdowns mostly already worked, but the documentation is necessary since the remote dropdowns work differently.\r\n\r\nI added listeners on select2-focus and select2-blur to wrap ngFocus and ngBlur events, since they were not being fired.\r\n\r\nSelect2's will no longer close on window scroll. It made infinite scrolling almost impossible as the select would close before the options were loaded."},"comment":{"url":"https://api.github.com/repos/Availity/availity-angular/issues/comments/110982489","html_url":"https://github.com/Availity/availity-angular/pull/46#issuecomment-110982489","issue_url":"https://api.github.com/repos/Availity/availity-angular/issues/46","id":110982489,"user":{"login":"robmcguinness","id":281070,"avatar_url":"https://avatars.githubusercontent.com/u/281070?v=3","gravatar_id":"","url":"https://api.github.com/users/robmcguinness","html_url":"https://github.com/robmcguinness","followers_url":"https://api.github.com/users/robmcguinness/followers","following_url":"https://api.github.com/users/robmcguinness/following{/other_user}","gists_url":"https://api.github.com/users/robmcguinness/gists{/gist_id}","starred_url":"https://api.github.com/users/robmcguinness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robmcguinness/subscriptions","organizations_url":"https://api.github.com/users/robmcguinness/orgs","repos_url":"https://api.github.com/users/robmcguinness/repos","events_url":"https://api.github.com/users/robmcguinness/events{/privacy}","received_events_url":"https://api.github.com/users/robmcguinness/received_events","type":"User","site_admin":false},"created_at":"2015-06-11T03:00:26Z","updated_at":"2015-06-11T03:00:26Z","body":"@JamieCrisman I was hoping the `avCodesResource` module, which is the module that performs the ajax calls, would be the class that transforms the data that can be interpreted by Select2.  Each resource class is derived from `AvApiResource` which has before/after functions for create/update/query that can mutate the data.  Additionally each resource module can have helper methods that can help with pagination.\r\n\r\n\r\n```js\r\n// AvDropdownController\r\nthis.query = function(options) {\r\n  self.queryFn(options).then(function(response) {\r\n    // data should already be in a form that Select2 to can interpret\r\n    options.callback({more: response.more, results: response.results});\r\n  });\r\n};\r\n```\r\n\r\n```js\r\n// avCodesResource.js\r\n\r\nvar AvCodesResourceFactory = function(AvApiResource) {\r\n\r\n    var AvCodesResource = function() {\r\n      AvApiResource.call(this, 'codes');\r\n    };\r\n\r\n    angular.extend(AvCodesResource.prototype, AvApiResource.prototype, {\r\n\r\n      getCodes: function() {\r\n\r\n        return this.query().then(function(response) {\r\n\r\n          var myResults = response.data.codes;\r\n          if(_.isEmpty(myResults[0].id)){\r\n            _.each(myResults, function(code){\r\n              code.id = code.code;\r\n            });\r\n          }\r\n\r\n          var moreVal = (( (response.data.offset/response.data.limit) -1) * 50) < response.data.totalCount;\r\n         \r\n          // send format Select2 can understand\r\n          return {\r\n            more: moreVal,\r\n            results: myResults\r\n          };\r\n\r\n        });\r\n      }\r\n\r\n    });\r\n\r\n    return new AvCodesResource();\r\n  };\r\n\r\n  availity.core.factory('avCodesResource', AvCodesResourceFactory);\r\n```\r\n\r\n```js\r\n// some controller\r\n\r\navaility.demo.controller('DropdownController', function(..., avCodesResource) {\r\n  $scope.getCodes = function() {\r\n    return avCodesResource.getCodes();\r\n  };\r\n}\r\n```\r\n\r\nsomething like that."}}