Lille
2012-Sep-20 23:12 UTC
jQueryUI autocomplete (Rails 3.1): can''t get source as url to work
Hey, I''m able to duplicate everything in Ryan Bates'' screencast on jQueryUI autocomplete (#102<http://railscasts.com/episodes/102-auto-complete-association-revised>), except for the piece that calls the server for completion data. Here is my view html: <input data-autocomplete-source="/searches" id="search-markets" name="search-markets" placeholder="market keyword and/or location" size="50" type="text" autocomplete="off"> Now, this coffeescript works... $(''#search-markets'').autocomplete source: [''foo'', ''food'', ''four''] ...whereas, this coffeescript trying to tap the server... $(''#search-markets'').autocomplete -> source: $(''#search-markets'').data(''autocomplete-source'') ...results in http POST calls to the root and not the data-autocomplete-source value of ''/searches''. Bates''s railscast uses a textfield in the context of a RESTful form, but I don''t expect this difference between his code and mine should explain my unexpected POST. Any thoughts? Lille -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/jZaSqsd38YQJ. For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Sep-21 00:10 UTC
Re: jQueryUI autocomplete (Rails 3.1): can''t get source as url to work
On Fri, Sep 21, 2012 at 9:12 AM, Lille <lille.penguini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey, > > I''m able to duplicate everything in Ryan Bates'' screencast on jQueryUI > autocomplete (#102<http://railscasts.com/episodes/102-auto-complete-association-revised>), > except for the piece that calls the server for completion data. > > Here is my view html: > > <input data-autocomplete-source="/searches" id="search-markets" > name="search-markets" placeholder="market keyword and/or location" > size="50" type="text" autocomplete="off"> >> Now, this coffeescript works... > > $(''#search-markets'').autocomplete > source: [''foo'', ''food'', ''four''] > > ...whereas, this coffeescript trying to tap the server... > > $(''#search-markets'').autocomplete -> > source: $(''#search-markets'').data(''autocomplete-source'') > > ...results in http POST calls to the root and not the > data-autocomplete-source value of ''/searches''. >There seems to be nothing wrong in your code. All I can think of that causes this is if another dom element has an id of search-markets. Can you confirm that your view only has one dom with this id?> > Bates''s railscast uses a textfield in the context of a RESTful form, but I > don''t expect this difference between his code and mine should explain my > unexpected POST. > > Any thoughts? > > Lille > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/jZaSqsd38YQJ. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Lille
2012-Sep-21 00:25 UTC
Re: jQueryUI autocomplete (Rails 3.1): can''t get source as url to work
> > > There seems to be nothing wrong in your code. All I can think of that > causes this is if another dom element > has an id of search-markets. Can you confirm that your view only has one > dom with this id? >Yes, I confirm. I modified the code to ensure no interference... $(''#search-markets'').autocomplete -> source: "/searches" For what it''s worth, the coffeescript compiles to this... $(''#search-markets'').autocomplete(function() { return { source: "/searches" }; }); I see other approaches using more of the autocompletion settings, including callbacks, but I wonder why my simple attempt fails. Lille -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/jzbiAgt8o7UJ. For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Sep-21 00:43 UTC
Re: jQueryUI autocomplete (Rails 3.1): can''t get source as url to work
On Fri, Sep 21, 2012 at 10:25 AM, Lille <lille.penguini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> >> There seems to be nothing wrong in your code. All I can think of that >> causes this is if another dom element >> has an id of search-markets. Can you confirm that your view only has one >> dom with this id? >> > > Yes, I confirm. I modified the code to ensure no interference... > > $(''#search-markets'').autocomplete -> > source: "/searches" > > For what it''s worth, the coffeescript compiles to this... > > $(''#search-markets'').autocomplete(function() { return { source: > "/searches" }; }); >Ah it''s stupid of me not to see the difference. Remove -> and it should work.> > I see other approaches using more of the autocompletion settings, > including callbacks, but I wonder why my simple attempt fails. > > Lille > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/jzbiAgt8o7UJ. > > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Lille
2012-Sep-21 01:31 UTC
Re: jQueryUI autocomplete (Rails 3.1): can''t get source as url to work
> There seems to be nothing wrong in your code. All I can think of that >>> causes this is if another dom element >>> has an id of search-markets. Can you confirm that your view only has >>> one dom with this id? >>> >> >> Yes, I confirm. I modified the code to ensure no interference... >> >> $(''#search-markets'').autocomplete -> >> source: "/searches" >> >> For what it''s worth, the coffeescript compiles to this... >> >> $(''#search-markets'').autocomplete(function() { return { source: >> "/searches" }; }); >> > > Ah it''s stupid of me not to see the difference. Remove -> and it should > work. >No, doing that results in no network activity from the widget, at all -- kills it. This is what the code compiles to without ''->''... $(''#search-markets'').autocomplete({ source: "/searches" }); That looks better to me, but it''s not happening. Lille -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/lnmGrpvB_1IJ. For more options, visit https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2012-Sep-21 01:41 UTC
Re: jQueryUI autocomplete (Rails 3.1): can''t get source as url to work
On Fri, Sep 21, 2012 at 11:31 AM, Lille <lille.penguini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > There seems to be nothing wrong in your code. All I can think of that >>>> causes this is if another dom element >>>> has an id of search-markets. Can you confirm that your view only has >>>> one dom with this id? >>>> >>> >>> Yes, I confirm. I modified the code to ensure no interference... >>> >>> $(''#search-markets'').**autocomplete -> >>> source: "/searches" >>> >>> For what it''s worth, the coffeescript compiles to this... >>> >>> $(''#search-markets'').**autocomplete(function() { return { source: >>> "/searches" }; }); >>> >> >> Ah it''s stupid of me not to see the difference. Remove -> and it should >> work. >> > > No, doing that results in no network activity from the widget, at all -- > kills it. > > This is what the code compiles to without ''->''... > > $(''#search-markets'').autocomplete({ > source: "/searches" > }); > > That looks better to me, but it''s not happening. >That''s the right js. You should paste here the code which handles requests to /searches.> > Lille > > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/lnmGrpvB_1IJ. > > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Lille
2012-Sep-21 02:03 UTC
Re: jQueryUI autocomplete (Rails 3.1): can''t get source as url to work
> > This is what the code compiles to without ''->''... >> >> $(''#search-markets'').autocomplete({ >> source: "/searches" >> }); >> >> That looks better to me, but it''s not happening. >> > > That''s the right js. You should paste here the code which handles > requests to /searches. >Here''s a curl to confirm that the resource works... curl ''http://localhost:3000/searches?term=s'' ["seom","some marker","some market","some market","some market","some market","some market","some market","some market",...] Could it be the response format? I don''t think so, I get positive results when I do something like this... $("input#search-markets").autocomplete( source: (request, response) -> $.getJSON("/searches", { term: request }, (response) -> response(result) ) # $.each(result, (i, val) -> console.log("fuck: "+val))) select: (event, ui) -> window.location = ui.item.value false ) I''d just like to know why the simple form fails. I guess I''ll drop this soon, as it feels idiosyncratic without broader interest. Final call for any comments! Lille -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/bh_akI8gUkQJ. For more options, visit https://groups.google.com/groups/opt_out.
Lille
2012-Sep-27 23:16 UTC
Re: jQueryUI autocomplete (Rails 3.1): can''t get source as url to work
> > I''d just like to know why the simple form fails. >Turns out that a customized autocompletion file that I had included from vendor/assets/javascripts was superseding jquery-ui and, once removed, I got the expected behavior -- so, this was completely one-off. Sorry not to have noticed it, sooner. Lille -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/d6Q1Ss7IfGQJ. For more options, visit https://groups.google.com/groups/opt_out.
Reasonably Related Threads
- disable ''tab'' key wish for incremental autocomplete of textareas
- Rails and Service Oriented Architecture (SOA): any downsides?
- autocomplete=off not working on Firefox
- Autocomplete broken after update to Rails 1.0
- autocomplete field in ajax response html - css does not get applied.