So this returns the correct value in params[:data]:
    <%= link_to_remote 'Send Request', :url => {:controller =>
"requests", :action => "create",
      :date => @date, :weekday => @weekday, :id => @id}, :with =>
"'data='+newFunction()",
      :update => 'request_sent' %>

but this returns nil:
        <% form_remote_tag(:url => {:controller => 'requests', :action
=>'create'},
          :with => "'data='+newFunction()", :update => 'request_sent')
do %>
        <%= text_field "request", "request" %><br/>
        <%= submit_tag 'Send Request' %>

am I using :with within the form_remote_tag helper correctly?  Are you
able to use it with form_remote_tag?  Thanks.

On Oct 3, 1:46 am, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On Oct 3, 9:43 am, David <[EMAIL PROTECTED]> wrote:
>
> > result() is the name of a javascript function that I have defined
> > within a script in the head element.  calling it in :with sets this
> > result to data, which can then be accessed with params[:data] in the
> > action create.
>
> Well your initial post is using a function called request :-)
> Make sure your function returns appropriately format data, other than
> that you're going to have to be more explicit about how it doesn't
> work.
>
> Fred
>
> > On Oct 3, 1:34 am, Frederick Cheung <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Oct 3, 7:43 am, David <[EMAIL PROTECTED]> wrote:> I am trying to pass 
> > > the result from a javascript function along with
> > > > the result from a text_field with form_remote_tag.  This is what I
> > > > have so far, but no go:
>
> > > >     <% form_remote_tag(:url => {:controller => 'requests', :action =>
> > > > 'create'},  :with => "'data='+request()", :update => 'request_sent' )
> > > > do %>
> > > >         <%= text_field "request", "request" %><br/>
> > > >         <%= submit_tag 'Send Request' %>
> > > >     <% end %>
>
> > > Short answer: learn more javascript
> > > Long Answer: The behaviour of with is basically identical for
> > > link_to_remote and form_remote_tag. There is no function called
> > > request, so this can't work as is. Functions are not automatically
> > > added for input element. $F('foo') returns the value of the element
> > > with id foo and should do the trick (just check in the generated html
> > > what the id of the text field is). I also wrote some stuff about :with
> > > athttp://www.spacevatican.org/2008/5/17/with-or-without-you-link_to_rem...
> > > Having said all that you don't need any of that here - the form will
> > > submit the value of the text field anyway, no :with needed.
>
> > > Fred
>
> > > Fred
>
> > > > I was able to get this to work with link_to_remote with the following
> > > > code:
>
> > > > <br/><%= link_to_remote 'Update availability', :url => {:action =>
> > > > "array"}, :with => "'data='+test()", :update => 'testing' %>
>
> > > > where test() is the javascript function.  This allows me to access the
> > > > result of the test function in params[:data].  It seems that I should
> > > > be able to do the same with form_remote_tag, but I have been
> > > > unsuccessful.   Maybe a syntax mistake?  Maybe not possible?
--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-talk@googlegroups.com
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