{"action":"opened","issue":{"url":"https://api.github.com/repos/sferik/rails_admin/issues/2457","labels_url":"https://api.github.com/repos/sferik/rails_admin/issues/2457/labels{/name}","comments_url":"https://api.github.com/repos/sferik/rails_admin/issues/2457/comments","events_url":"https://api.github.com/repos/sferik/rails_admin/issues/2457/events","html_url":"https://github.com/sferik/rails_admin/issues/2457","id":115432335,"number":2457,"title":"Changing available values for autocomplete input issue.","user":{"login":"SuperMasterBlasterLaser","id":8684688,"avatar_url":"https://avatars.githubusercontent.com/u/8684688?v=3","gravatar_id":"","url":"https://api.github.com/users/SuperMasterBlasterLaser","html_url":"https://github.com/SuperMasterBlasterLaser","followers_url":"https://api.github.com/users/SuperMasterBlasterLaser/followers","following_url":"https://api.github.com/users/SuperMasterBlasterLaser/following{/other_user}","gists_url":"https://api.github.com/users/SuperMasterBlasterLaser/gists{/gist_id}","starred_url":"https://api.github.com/users/SuperMasterBlasterLaser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SuperMasterBlasterLaser/subscriptions","organizations_url":"https://api.github.com/users/SuperMasterBlasterLaser/orgs","repos_url":"https://api.github.com/users/SuperMasterBlasterLaser/repos","events_url":"https://api.github.com/users/SuperMasterBlasterLaser/events{/privacy}","received_events_url":"https://api.github.com/users/SuperMasterBlasterLaser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-06T04:36:51Z","updated_at":"2015-11-06T04:36:51Z","closed_at":null,"body":"Hello.\r\n\r\nWhen model has `belongs_to` association, in `create` and `edit` action there will be `combo box` that helps to associate other model to this. I have found out that field for assigning models are more complicated than I thought.\r\n\r\nAccording to source code of this field:\r\n      1. It has hidden `<select>` tag that keeps all avilable values.\r\n      2. Users sees `<input>` tag which has javascript for autocomplete\r\n      3. When users clicks to drop-down button or types to input, it creates dynamically `<ul>` tag with available elements.\r\n      4. When users choose one of options some kind of javascript method changes `<select>` tag's value.\r\n\r\nI think this field uses JQueryUI's autocomplete library. It loads ALL available models that could be associated.\r\n\r\nHowever, this gives new problem. For example:\r\n\r\nIf I have models `Shop`, `Item` and `Category`. They have these associations:\r\n      1. Shop `has_and_belongs_to_many` Categories\r\n      2. Shop `has_many` Items\r\n      3. Category `has_many` Items\r\n\r\nWhen Users creates his own Shop he associates multiple Categories. Then Users tries to create Item and he need to choose Shop and Category. Combobox shows ALL available Categories for Item creation.\r\n\r\nI need to show only categories that has selected Shop. imagine if there are 1000 Categories and Shop has only 3 of them.\r\n\r\nI have created my own `ui.js` javascript file in `assets/javascripts/rails_admin/custom/` directory. Created AJAX functions that will change values of `<select>` tag by value of other `<select>` tag. However, it DOES NOT change available values for autcomplete. \r\n\r\nI think script for autocomplete preloads all data when page is loaded and works independently from values of `<select>` tags.\r\n\r\nIs it possible to reaload avaliable data for autocomplete input?"}}