Googling for this has not solved my problems. Is there a particular site that is recommened for its examples and tutorials on Rails'' AJAX capabilities? I know exactly what I want to do, just not how to do it, and am looking for some code to pore over. 1) I have a dropdown that represents the name of an image in a library. When the dropdown value is changed, I would like to refresh the current display and show the image that is now selected. Most of the examples I''m finding are during the remote submission of the form as a whole, I can''t seem to find much that executes on an onChange event. 2) I have an object Foo that has_many Baz objects. During the creation or editing of a Foo object I''d like to independently be able to add/remove Baz objects without having to refresh the entire form each time. Is this even possible? I don''t necessarily want to update any of the other fields of the Foo object when somebody hits the "Add new Baz" button. Thanks! -- Posted via http://www.ruby-forum.com/.
Duane,
How about using remote_function? The example seems to fit your
problem...
<select id="options" onchange="<%=
remote_function(:update =>
"options",
:url => { :action => :update_options }) %>">
<option value="0">Hello</option>
<option value="1">World</option>
</select>
Marcus
-----Original Message-----
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Duane Morin
Sent: Friday, June 02, 2006 10:48 AM
To: rails@lists.rubyonrails.org
Subject: [Rails] Where are the best AJAX examples?
Googling for this has not solved my problems. Is there a particular
site that is recommened for its examples and tutorials on Rails'' AJAX
capabilities? I know exactly what I want to do, just not how to do it,
and am looking for some code to pore over.
1) I have a dropdown that represents the name of an image in a library.
When the dropdown value is changed, I would like to refresh the current
display and show the image that is now selected. Most of the examples
I''m finding are during the remote submission of the form as a whole, I
can''t seem to find much that executes on an onChange event.
2) I have an object Foo that has_many Baz objects. During the creation
or editing of a Foo object I''d like to independently be able to
add/remove Baz objects without having to refresh the entire form each
time. Is this even possible? I don''t necessarily want to update any
of
the other fields of the Foo object when somebody hits the "Add new
Baz"
button.
Thanks!
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
Duane Morin wrote:> Googling for this has not solved my problems. Is there a particular > site that is recommened for its examples and tutorials on Rails'' AJAX > capabilities? I know exactly what I want to do, just not how to do it, > and am looking for some code to pore over. > > 1) I have a dropdown that represents the name of an image in a library. > When the dropdown value is changed, I would like to refresh the current > display and show the image that is now selected. Most of the examples > I''m finding are during the remote submission of the form as a whole, I > can''t seem to find much that executes on an onChange event. > > 2) I have an object Foo that has_many Baz objects. During the creation > or editing of a Foo object I''d like to independently be able to > add/remove Baz objects without having to refresh the entire form each > time. Is this even possible? I don''t necessarily want to update any of > the other fields of the Foo object when somebody hits the "Add new Baz" > button. > > Thanks!For #1 you don''t need ajax at all, just javascript. <%= image_tag foo.image, :id => ''image'' %> <%= select ''foo'', ''image'', [[''image 1'', ''/images/foo.jpg''], [''image 2'', ''/images/bar.jpg]], :onchange => "$(''image'').src = this.value" %> Note that you still must submit the form to save this however. -- Posted via http://www.ruby-forum.com/.
If you''re really looking for how to implement Rails-styled AJAX and
Javascript then you''re looking for http://script.aculo.us
- Danger
On 6/2/06, Duane Morin <dmorin@gmail.com> wrote:>
> Googling for this has not solved my problems. Is there a particular
> site that is recommened for its examples and tutorials on Rails''
AJAX
> capabilities? I know exactly what I want to do, just not how to do it,
> and am looking for some code to pore over.
>
> 1) I have a dropdown that represents the name of an image in a library.
> When the dropdown value is changed, I would like to refresh the current
> display and show the image that is now selected. Most of the examples
> I''m finding are during the remote submission of the form as a
whole, I
> can''t seem to find much that executes on an onChange event.
>
> 2) I have an object Foo that has_many Baz objects. During the creation
> or editing of a Foo object I''d like to independently be able to
> add/remove Baz objects without having to refresh the entire form each
> time. Is this even possible? I don''t necessarily want to update
any of
> the other fields of the Foo object when somebody hits the "Add new
Baz"
> button.
>
> Thanks!
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060602/b8b2dfe5/attachment.html