{"action":"created","issue":{"url":"https://api.github.com/repos/running-coder/jquery-typeahead/issues/96","labels_url":"https://api.github.com/repos/running-coder/jquery-typeahead/issues/96/labels{/name}","comments_url":"https://api.github.com/repos/running-coder/jquery-typeahead/issues/96/comments","events_url":"https://api.github.com/repos/running-coder/jquery-typeahead/issues/96/events","html_url":"https://github.com/running-coder/jquery-typeahead/issues/96","id":113131606,"number":96,"title":"typeahead feed via sessionStorage","user":{"login":"marccollin","id":4097381,"avatar_url":"https://avatars.githubusercontent.com/u/4097381?v=3","gravatar_id":"","url":"https://api.github.com/users/marccollin","html_url":"https://github.com/marccollin","followers_url":"https://api.github.com/users/marccollin/followers","following_url":"https://api.github.com/users/marccollin/following{/other_user}","gists_url":"https://api.github.com/users/marccollin/gists{/gist_id}","starred_url":"https://api.github.com/users/marccollin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marccollin/subscriptions","organizations_url":"https://api.github.com/users/marccollin/orgs","repos_url":"https://api.github.com/users/marccollin/repos","events_url":"https://api.github.com/users/marccollin/events{/privacy}","received_events_url":"https://api.github.com/users/marccollin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-24T03:05:14Z","updated_at":"2015-10-24T04:55:30Z","closed_at":null,"body":"Hi\r\n\r\ni try to feed the typeaead with value in the sessionStorage.\r\n\r\nactually, typeahead display nothing\r\n\r\n```\r\n$('#referenceCity').typeahead({\r\n            minLength: 3,\r\n            display: \"city\",\r\n            source: {\r\n                data: sessionStorage.getItem(\"city\")\r\n            }, callback: {\r\n                onClick: function (node, a, item, event) {\r\n                    console.log('onClick function triggered');\r\n                    $('#referenceCityId').val(item.cityId);\r\n                }\r\n            }\r\n        });\r\n```\r\n\r\nmy session storage is feeded like this\r\n\r\n```\r\nvar city = sessionStorage.getItem(\"city\");\r\n    if (city == null) {\r\n        $.ajax({\r\n            url: 'http://localhost:8080/rest/cities',\r\n            type: 'GET',\r\n            success: function (json) {\r\n                sessionStorage.setItem(\"city\", JSON.stringify(json));\r\n            }\r\n        });\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/running-coder/jquery-typeahead/issues/comments/150754240","html_url":"https://github.com/running-coder/jquery-typeahead/issues/96#issuecomment-150754240","issue_url":"https://api.github.com/repos/running-coder/jquery-typeahead/issues/96","id":150754240,"user":{"login":"running-coder","id":7377382,"avatar_url":"https://avatars.githubusercontent.com/u/7377382?v=3","gravatar_id":"","url":"https://api.github.com/users/running-coder","html_url":"https://github.com/running-coder","followers_url":"https://api.github.com/users/running-coder/followers","following_url":"https://api.github.com/users/running-coder/following{/other_user}","gists_url":"https://api.github.com/users/running-coder/gists{/gist_id}","starred_url":"https://api.github.com/users/running-coder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/running-coder/subscriptions","organizations_url":"https://api.github.com/users/running-coder/orgs","repos_url":"https://api.github.com/users/running-coder/repos","events_url":"https://api.github.com/users/running-coder/events{/privacy}","received_events_url":"https://api.github.com/users/running-coder/received_events","type":"User","site_admin":false},"created_at":"2015-10-24T04:55:30Z","updated_at":"2015-10-24T04:55:30Z","body":"it seem to me that some \"fail-safe\" code is missing from your implementation, here is how I would have put it together\r\n\r\n``` javascript\r\nsessionStorage.getItem(\"city\") && initTypeahead() || $.ajax({\r\n    url: 'http://localhost:8080/rest/cities',\r\n    type: 'GET',\r\n    success: function (json) {\r\n        sessionStorage.setItem(\"city\", JSON.stringify(json));\r\n        initTypeahead();\r\n    }\r\n});\r\n\r\n\r\nfunction initTypeahead() {\r\n    $('#referenceCity').typeahead({\r\n        minLength: 3,\r\n        display: \"city\",\r\n        source: {\r\n            // @TODO Make sure to pass an array of objects and not a string\r\n            data: JSON.parse(sessionStorage.getItem(\"city\"))\r\n        }, callback: {\r\n            onClick: function (node, a, item, event) {\r\n                console.log('onClick function triggered');\r\n                $('#referenceCityId').val(item.cityId);\r\n            }\r\n        },\r\n        // @TODO Debug should point you out potential errors inside the console (using jquery.typeahead.js, not min)\r\n        debug: true\r\n    });\r\n}\r\n```"}}