this.source is not a function
I'm trying to use autocomplete in a modal, so to get it working at all I had to
- jQuery(function() {
- return $(this).bind("ajax:success", function() {
- return jQuery(function() {
- return $('#mail_recipient').autocomplete({
- source: $('#mail_recipient').data('autocomplete_source')
- });
- });
- });
- });
because it wouldn't bind to an ajax loaded partial form in rails. in the form i've got:
- <%= f.input :recipient, data: { autocomplete_source: ['asdf', 'qwer', 'zxcv']} %>
which will be mails_path eventually. if I put the ['asdf'] source in the jquery, it works, but otherwise i get an uncaught type error: this.source is not a function, pointing to:
- _search: function( value ) {
- this.pending++;
- this._addClass( "ui-autocomplete-loading" );
- this.cancelSearch = false;
- this.source( { term: value }, this._response() ); <---
- },
just wondering if this is the best implementation, thanks!