Hello, I am trying to create a button on the list page that triggers an action, like for example a list of type of wood, and the button adds dynamically upon clicking the number of packages linked to a certain type of wood. The list of wood should be updated automatically, i am able to add more wood packages but the list page is not updated automatically. (unless i refresh) I tried using render :partial in the function... nothing. Any idea how to make it work properly without reloading the whole page? CN -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
so you have a button that increments the number of packages, but the number
of packages displayed does not update when the button is clicked to add
another package?
give the element in which you write the number of packages an id, for
example id="<%= ''wood'' + wood.id.to_s %>".
then in your controller
def incrementing_function
wood = Wood.find(params[:wood_id]
wood.packages += 1
wood.save
render(update) do |page|
page.replace_html "wood" + wood.id.to_s, :partial =>
''partial you
mentioned'', :locals => {:wood => wood}
end
end
if you use the partial you mentioned to render the original number of
packages then you will replace the partial with the same partial, populated
with the updated wood object.
hope that helps, if not, elaborate on your problem and maybe someone else
will be able to help.
Ivor
On 3/23/07, Constantin Nicolaou
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> Hello,
>
> I am trying to create a button on the list page that triggers an action,
> like for example a list of type of wood, and the button adds dynamically
> upon clicking the number of packages linked to a certain type of wood.
> The list of wood should be updated automatically, i am able to add more
> wood packages but the list page is not updated automatically. (unless i
> refresh)
> I tried using render :partial in the function... nothing.
>
> Any idea how to make it work properly without reloading the whole page?
>
> CN
>
> --
> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thanks Ivor,
It is a voting button for a specific candidate in the list.
All programming process is workign fine, the thing is that i want to
enable dynamic update of the # of votes (if possible using ajax)
I have these lines in my candidates list:
<%= form_remote_tag(:url => { :action => ''vote'',
:id => cand.id },
:update => ''voting'' +
cand.id.to_s )
%><br/>
<div id="<%= ''voting'' + cand.id.to_s
%>">
<%=h cand.votes %><br/>
</div>
<%= submit_tag("Add Voter") %>
<%= end_form_tag %>
and the following controller function:
def vote
cand = Candidates.find(params[:id])
cand.votes += 1
cand.save
render(update) do |page|
page.replace_html "voting" + cand.id.to_s, :partial =>
''list'',
:locals => {:candidates => candidates}
end
end
The error i am getting is the following:
"ActionController::DoubleRenderError in CandidatesController#vote
Can only render or redirect once per action"
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Costi Nicolaou wrote:
I also created an .RJS file for highliting:
page.visual_effect :highlight, "voting#{@candidates.id}"
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Costi Nicolaou wrote:> <%= form_remote_tag(:url => { :action => ''vote'', :id => cand.id }, > :update => ''voting'' + cand.id.to_s )For a vote, why not use observe_form() and submit the vote at click time? Why make the user click twice just to vote once? You don''t work for Diebold, do you? (:-) -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Diebold??!!! nooo Can you pls elaborate on your idea? How the current one is posting twice? Thx in advance -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Costi Nicolaou wrote:> Can you pls elaborate on your idea? How the current one is posting > twice?Look observe_form() up. Your current plan makes the user click their mouse on the check-box, then click on the Submit button. If you instead observe the form, it will post each time the user changes it. In some usability contexts, such as voting, the post should be instant. Consider the Rating button on Google Groups posts. In other usability contexts, the users should make many changes and send them all at once. That''s what Submit buttons are for. -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---