{"action":"created","issue":{"url":"https://api.github.com/repos/crucialfelix/django-ajax-selects/issues/170","repository_url":"https://api.github.com/repos/crucialfelix/django-ajax-selects","labels_url":"https://api.github.com/repos/crucialfelix/django-ajax-selects/issues/170/labels{/name}","comments_url":"https://api.github.com/repos/crucialfelix/django-ajax-selects/issues/170/comments","events_url":"https://api.github.com/repos/crucialfelix/django-ajax-selects/issues/170/events","html_url":"https://github.com/crucialfelix/django-ajax-selects/issues/170","id":156597823,"number":170,"title":"Failure on inlines with zero existing rows","user":{"login":"murraylchapman","id":19542516,"avatar_url":"https://avatars.githubusercontent.com/u/19542516?v=3","gravatar_id":"","url":"https://api.github.com/users/murraylchapman","html_url":"https://github.com/murraylchapman","followers_url":"https://api.github.com/users/murraylchapman/followers","following_url":"https://api.github.com/users/murraylchapman/following{/other_user}","gists_url":"https://api.github.com/users/murraylchapman/gists{/gist_id}","starred_url":"https://api.github.com/users/murraylchapman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/murraylchapman/subscriptions","organizations_url":"https://api.github.com/users/murraylchapman/orgs","repos_url":"https://api.github.com/users/murraylchapman/repos","events_url":"https://api.github.com/users/murraylchapman/events{/privacy}","received_events_url":"https://api.github.com/users/murraylchapman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/crucialfelix/django-ajax-selects/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-05-24T20:09:51Z","updated_at":"2016-09-05T08:40:08Z","closed_at":null,"body":"I'm seeing a problem when using ajax_select in a TabularInline form that has no existing rows.\r\n\r\nThe problem is that ajax_select attaches the jQuery-UI autocomplete widget to the input field in the hidden row and when that gets cloned to add a row the internal variables that jQuery uses for housekeeping aren't updated to point to the cloned row.  I've encountered a similar problem when using autoNumeric; the only way to get it to work is make sure you don't attach stuff to anything in the hidden row; you've got to do it *after* cloning.\r\n\r\nI *think* that's what the \"dirty loop\" is designed to compensate for; it seems to work somehow when there's existing rows, but it's hard to tell because I'm not sure what it's actually attempting to do.  Certainly when there's zero existing rows the \"minus 2\" logic results in an html_id that doesn't map to anything.\r\n\r\nI was able to fix things by replacing the \"dirty loop\" with this:\r\n\r\n    /* Don't attach to fields in the hidden row; we attach upon row add  */\r\n    if (html_id.indexOf('__prefix__') !== -1) {\r\n        return;\r\n    }\r\n\r\n...which seems to work in all cases I tried it in.  I'm not sure if there are unintended side-effects because I'm not really sure what the loop is trying to do.\r\n\r\n(Django 1.7, python 2.7)\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/crucialfelix/django-ajax-selects/issues/comments/244690823","html_url":"https://github.com/crucialfelix/django-ajax-selects/issues/170#issuecomment-244690823","issue_url":"https://api.github.com/repos/crucialfelix/django-ajax-selects/issues/170","id":244690823,"user":{"login":"crucialfelix","id":218738,"avatar_url":"https://avatars.githubusercontent.com/u/218738?v=3","gravatar_id":"","url":"https://api.github.com/users/crucialfelix","html_url":"https://github.com/crucialfelix","followers_url":"https://api.github.com/users/crucialfelix/followers","following_url":"https://api.github.com/users/crucialfelix/following{/other_user}","gists_url":"https://api.github.com/users/crucialfelix/gists{/gist_id}","starred_url":"https://api.github.com/users/crucialfelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crucialfelix/subscriptions","organizations_url":"https://api.github.com/users/crucialfelix/orgs","repos_url":"https://api.github.com/users/crucialfelix/repos","events_url":"https://api.github.com/users/crucialfelix/events{/privacy}","received_events_url":"https://api.github.com/users/crucialfelix/received_events","type":"User","site_admin":false},"created_at":"2016-09-05T08:40:08Z","updated_at":"2016-09-05T08:40:08Z","body":"The install.sh script in examples does this for you \r\n\r\n    ./install.sh 1.9\r\n\r\n"}}
{"actor":{"display_login":"crucialfelix"}}