Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery-UI Autocomplete Widget passing multiple params to Rails server-side datasource
    primarykey
    data
    text
    <p>There was a question in the comments section of the AutoComplete Railscast that was unanswered and I need help with the same issue. <a href="http://railscasts.com/episodes/102-auto-complete-association-revised?view=comments#comment_159833" rel="nofollow noreferrer">http://railscasts.com/episodes/102-auto-complete-association-revised?view=comments#comment_159833</a></p> <p>I'm implementing jQuery-UI Autocomplete with the datasource coming from a Rails Controller which in turn is calling the Foursquare API. The Foursquare API requires 2 parameters (a "query" and a "lat/long" value).</p> <p>The Autocomplete widget's default param that it sends to the Rails controller is params[:term] which contains the "query". I need the Autocomplete Widget to pull the value from another text_field (let's call it the geocode_location field) and pass that as the "latlong" param. </p> <p>So effectively, the GET request to the Rails Controller would be </p> <p>Request URL:<a href="http://localhost:3000/foursquare?ll=37.7+-122.5&amp;term=McDonalds" rel="nofollow noreferrer">http://localhost:3000/foursquare?ll=37.7+-122.5&amp;term=McDonalds</a></p> <p>and not </p> <p>Request URL: URL:<a href="http://localhost:3000/foursquare?term=McDonalds" rel="nofollow noreferrer">http://localhost:3000/foursquare?term=McDonalds</a> </p> <p>Below is my current coffeescript file. I need to try to pass it extraParams or some way to let it know to pass a param named :latlong. How do I do that with Coffeescript and this type of data source?</p> <pre><code> $('[type="text"][name*="[location]"]').autocomplete source: $('[type="text"][name*="[location]"]').data('autocomplete-source') focus: (event, ui) -&gt; event.preventDefault() $(this).val ui.item.label select: (event, ui) -&gt; event.preventDefault() $(this).val ui.item.label $(this).siblings('[name*="[foursquare_id]"]').val ui.item.value </code></pre> <p>I'm not very familiar with Coffeescript syntax but really appreciate the help here. There is a similar question here but the data source for the autocomplete results is different. <a href="https://stackoverflow.com/questions/3803998/jquery-ui-autocomplete-with-extra-params-returned-data">jQuery UI - Autocomplete with extra params - returned data</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload