Is there a cleaner way to build the url in the following snippet?
$(function() {
$('#name').change(function() {
$.ajax({
url: "<%= url_for({action: 'lookup'}) %>" + "?term=" + this.value,
...
}
})
})
})
Note that I should not use a hard-coded URL, because this app should be
deployed at a sub-URI using Passenger.
--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice
on 2012-07-10 23:43
on 2012-07-11 00:16
On Tue, Jul 10, 2012 at 4:42 PM, Scott Ribe <scott_ribe@elevated-dev.com>wrote: > }) > > Note that I should not use a hard-coded URL, because this app should be > deployed at a sub-URI using Passenger. > > As far as I understood, you want to do a request to the lookup action in your controller. I recently discovered this *select*(object, method, choices, options = {}, html_options = {}) inside your html_options hash you can put something like this {data: {remote: true, url: url_for(controller: "your controller (if necessary)", action: "lookup")}} so whenever you choose an option it will do an ajax request with the selected value. Then you just need a handler in that view, or just have a lookup.js.erb file that handle the controller action HTH Javier Q.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.