i think changing the form_tag to

form_tag {:controller => 'mains', :action => 'search', :format => :js},
:remote => true do

should work. The brackets are there to separate the url_for options with the
html_options.

On Thu, Feb 3, 2011 at 5:10 PM, Matthias S. <[email protected]> wrote:

> Hi,
>
> I am using Rails 3.0.3 with jQuery ujs.
>
> I want to send a form remotely. The view template
> **mains/index.html.erb** containing the form looks as follows:
>
> ...
> <%= form_tag :remote => true, :controller => "mains", :action =>
> "search", :format => :js do %>
> <div class="dialog">
> <table>
> <tbody>
> <tr class="prop">
> <td valign="top" class="name">
> <%= label_tag(:location_start, "Location Start:") %>
> </td>
> <td valign="top">
> <%= text_field_tag(:location_start) %>
> </td>
> ...
> </tbody>
> </table>
> </div>
> <div class="buttons">
> <span class="button"><%= submit_tag("Search") %></span>
> </div>
> <% end %>
> ...
>
> The controller mains_controller.rb looks as follows (removed
> unnecessary stuff):
>
> class MainsController < ApplicationController
>
> def index
>  respond_to do |format|
>  format.html # index.html.erb
>  end
> end
>
> def search
>  respond_to do |format|
>  format.js { render :template => 'mains/search.js.erb'}
>  end
> end
>
> end
>
> The view template **mains/search.js.erb** has the following content:
>
> $('#search').html("<h1>Headline</h1>");
>
> I am using search.js.erb instead of search.js.rjs due to instructions in
> chapter "26.4 Write Less and Do More with JQuery" in Agile Web
> Development with Rails (4h edition). I also added :format => :js due
> to https://github.com/rails/jquery-ujs/issues/closed/#issue/52.
>
> When I call http://0.0.0.0:3000/mains/index and submit the form,
> it's actually not submitted remotely, but the browser loads
> http://0.0.0.0:3000/mains/search.js?remote=true instead. The browser
> outputs `$('#search').html("<h1>Headline</h1>");`, instead of executing
> the JavaScript by replacing div#search with `<h1>Headline</h1>` given.
>
> I tried to find a solution but wasen't successful so far... Could anyone
> help?
>
> --
> Posted via http://www.ruby-forum.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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>


-- 
-------------------------------------------------------------
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to