I need to do some JS processing in the client before contacting the
server (fwiw, this is for Google geocoding). The JS does its processing
and concocts a form to send back to the server. The latter part is
working fine.
In a previous iteration, I had the following. It activated the JS code
on any change to the text field, and worked (although now I know I
should use a text_field_tag rather than abusing a text_field):
<input type=“hidden” id=“authenticity_token” value="<%=
form_authenticity_token %>">
But now now that I’ve added another field, my instinct says to create a
form with a submit button. But I don’t see how to create a form that
does NOT submit HTML when the submit button is pushed. Here’s the
errant form. What I want is the “search” button to call
geocodeAddress() and nothing more.
<%= form_tag(premises_path, :remote => true) do %>
<%= hidden_field_tag(“authenticity_token”, form_authenticity_token,
:id => “authenticity_token”) %>
<%= label_tag(“address”, “Type an address:”) %>
<%= text_field_tag(“raw_address”, nil, :size => 96, :id =>
“raw_address”) %>
<%= label_tag(“occupants”, “Occupants:”) %>
<%= select_tag(“occupants”, options_for_select([0.5, …, 8.0], 2.0))
%>
<%= submit_tag(“search”, :onchange => “geocodeAddress()”) %>
<% end %>
Suggestions? (Perhaps I could just lose the form altogether…)
- ff
P.S.: Marnen, I know what you’re thinking! I’ll reframe it as UJS
once I get the basics working.