Autocomplete Error This.source Is Not A Function
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions typeerror this.source is not a function jquery autocomplete you might have Meta Discuss the workings and policies of this
Typeahead Uncaught Typeerror: This.source Is Not A Function
site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers typeerror: this.source is not a function this.source( { term: value }, this._response() ); or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a
Angularjs Typeerror This.source Is Not A Function
community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up “this.source is not a function” error while implementing autocomplete up vote 3 down vote favorite $(document).ready(function(){ var var_name=null; $('#id1').click(function(){ $.ajax({ type:"GET", url:" ggs.erm.servlet.setup5.Page", success:function(response){ var_name=response; console.log(response); } }) }); $("#id").autocomplete({source:var_name}); }); This is typeahead.js this.source is not a function the Code I am messing with,It says TypeError:this.source is not a function. Where I am wrong,Correct me??? javascript json jquery javascript-events share|improve this question edited Jan 30 '13 at 7:44 Ja͢ck 122k19154199 asked Jan 30 '13 at 7:29 user1909647 var var_name=null; instead declare var var_name=[ ]; –Pratik Bhatt Jan 30 '13 at 7:37 add a comment| 1 Answer 1 active oldest votes up vote 10 down vote accepted jQuery Ajax methods are non-blocking, so it looks like you're trying to set an auto-complete source before the previous method resolves. You probably want to move the autocomplete assignment into the success method of your .ajax() call. So, instead of what you have, use: $.ajax({ type: "GET", url: "ggs.erm.servlet.setup5.Page", success: function(response) { $("#id").autocomplete({ source: response }); } }); share|improve this answer answered Jan 30 '13 at 7:36 Tieson T. 13.9k33364 After indenting the code correctly you can even see that he put the assignment of var_
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss
Uncaught Typeerror This.source Is Not A Function Jquery Autocomplete
the workings and policies of this site About Us Learn more about
Jquery Ui Autocomplete Ajax
Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow $(...).autocomplete is not a function Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each http://stackoverflow.com/questions/14598743/this-source-is-not-a-function-error-while-implementing-autocomplete other. Join them; it only takes a minute: Sign up Getting the error in the autocomplete function of the jquery “this.source is not a function.” up vote 1 down vote favorite My code is : $.ajax({ type: "GET", url: "https://url.com", dataType: "json", success: function (data) { //$("#id").autocomplete({ source: response }); $("#search").autocomplete( { source: data, select: function (event, ui) { http://stackoverflow.com/questions/31156450/getting-the-error-in-the-autocomplete-function-of-the-jquery-this-source-is-not $("#search").val(ui.item.FirstName + " / " + ui.item.LastName); return false; } }).data("autocomplete")._renderItem = function (ul, item) { return $("
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn http://stackoverflow.com/questions/34489217/uncaught-typeerror-this-source-is-not-a-function-when-using-rails4-autocomplete more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Uncaught TypeError: this.source is not a function when using rails4-autocomplete up vote 3 down vote favorite 1 I'm currently trying to set up autocomplete on a search is not field. I am using the rails4-autocomplete gem. I've read the documentation here: https://github.com/peterwillcn/rails4-autocomplete and followed all the steps to make it work, and it does work. I start typing in the search box and I get the results I expected. My next step was to implement one-click search feature. When I click on the one of the autocomplete suggestions, I want the site to go to the corresponding page for that item. I used the advice is not a on this page called Autocomplete Magic with Rails at http://www.yoniweisbrod.com/autocomplete-magic-with-rails/ Basically you add an event hook that submits the search button when an item is selected. $( document ).ready(function() { $('.search-query').bind('railsAutocomplete.select', function(event, data { $('.search-me').trigger('click') }); }); This kind of works when I implement it, as in sometimes when I click on the item I want it goes to the page, and other times it doesn't go anywhere. It simply fills the text box with the item info but doesn't submit. In these instances I get a jQuery error that reads: Uncaught TypeError: this.source is not a function - autocomplete.self-3befc48aba87cead090cfd014562b2771a662ac6d2c8197b24c08b2d9f3d9f2d.js?body=1:440 Refreshing the page fixes the issue, which led me to think my javascript wasn't loading in the right order. So I implemented the jQuery Turbolinks gem to make sure that my jQuery event were always loading without page refreshes. This didn't help. For informational purposes, my jQuery looks as follows: $( "#username" ).autocomplete({ html: true }); Setting the html option to true allows me to render html in the search results. I've been googling, but so far no luck. Any ideas, anyone? Thanks! jquery ruby-on-rails jquery-ui autocomplete share|improve this question edited Dec 28 '15 at 16:44 asked Dec 28 '15 at 7:17 Nic 163 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote I believe you you didn't add source to the auto