AJAX form refreshing page

I am trying to have a page submit a form and have the result update a
div instead of reloading the page, but everything I try refreshes the
page. I thought the :update part would prevent a page refresh, but
perhaps I am leaving something out.
Here is an example of something I have tried:

<%= form_remote_tag :url => { :action => :enter },
:update => “position#{box_num}” %>

<%= submit_tag %>

def enter
#…process fields
render(:layout => false)
end

It looks like I am using Prototype Version: ‘1.6.0.1’
Any ideas?

On 2 May 2008, at 14:02, cumom wrote:

<%= submit_tag %>

It’s proabably not relevant, but the preferred way to do this is now

<% form_remote_tag :url => { :action => :enter }, :update =>
“position#{box_num}” do %>

<%= submit_tag %>
<% end %>

Does your page/layout include prototype?

Fred

Oh by the way, if it helps, the form_remote_tag code produces the
following:

I see the “return false” there in the javascript, which should at
least prevent it from submitting the form in the ordinary manner.

On May 2, 8:13 am, Frederick C. [email protected]
wrote:

It’s proabably not relevant, but the preferred way to do this is now

<% form_remote_tag :url => { :action => :enter }, :update =>
“position#{box_num}” do %>

<%= submit_tag %>
<% end %>

I tried something close to that at one point. The example I saw had
dashes before the closing %>'s and I think it had <%='s for the
opening tags. I have updated my code to the preferred way you
describe, but it is still doing the same thing.

Does your page/layout include prototype?

This shows up in the page.

And the file is there, so it should be getting it.

On 2 May 2008, at 14:16, cumom wrote:

name=“authenticity_token” type=“hidden”
value=“021ac9218aede727f7ed79f0185047a005c7c593” />

I see the “return false” there in the javascript, which should at
least prevent it from submitting the form in the ordinary manner.
It probably means that the code before the return false is raising an
exception. Installing firebug or similar should help you out. This
would happen for example if there was no div with id position8

Fred

I have heard about firebug, but have never used it. It looks like it
would be useful, thanks. Here is what it said:

element.dispatchEvent is not a function
http://127.0.0.1:3000/javascripts/prototype.js?1207561014
Line 3972
fire([Document pedigree], “dom:loaded”, undefined)prototype.js (line
3972)
_methodized()prototype.js (line 246)
fireContentLoadedEvent()prototype.js (line 4006)
[Break on this error] element.dispatchEvent(event);

I will try to step through it unless some has any ideas

On May 2, 8:37 am, Frederick C. [email protected]

On 2 May 2008, at 14:56, cumom wrote:

I have heard about firebug, but have never used it. It looks like it
would be useful, thanks. Here is what it said:

related to http://www.ruby-forum.com/topic/137465 ?

Fred

I have heard about firebug, but have never used it. It looks like it
would be useful, thanks. Here is what it said:

element.dispatchEvent is not a function
http://127.0.0.1:3000/javascripts/prototype.js?1207561014
Line 3972
fire([Document pedigree], “dom:loaded”, undefined)prototype.js (line
3972)
_methodized()prototype.js (line 246)
fireContentLoadedEvent()prototype.js (line 4006)
[Break on this error] element.dispatchEvent(event);

I will try to step through it unless some has any ideas

On May 2, 8:37 am, Frederick C. [email protected]

I remember reading about jquery and prototype conflicting, but I
thought, it’s working for me right now…

Thanks for the quick and efficient help.

On May 2, 9:04 am, Frederick C. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs