Paul Bergstrom
2013-May-31 19:44 UTC
Getting json data to div and partial after ajax call?
I''m able to get json data back after an ajax call and into a div. But how do I get it into html, styled format? How about getting it to a partial? How do I do that in coffeescript? -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/27f55d9596c7977ad612f3433528d425%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Benjamin Iandavid Rodriguez
2013-May-31 19:47 UTC
Re: Getting json data to div and partial after ajax call?
For what you say. After you get the JSON response the partial is already processed so you just need to update the correct div with the correct info. Use jQuery''s append or html properties to update your divs. 2013/5/31 Paul Bergstrom <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> I''m able to get json data back after an ajax call and into a div. But > how do I get it into html, styled format? > > How about getting it to a partial? How do I do that in coffeescript? > > -- > 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 unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/27f55d9596c7977ad612f3433528d425%40ruby-forum.com?hl=en-US > . > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAHRDpXpvysMbmCZO%3DMX4%3DZAqf-K-Ve4FAot6RX_4f%2BN5L0V3EQ%40mail.gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Paul Bergstrom
2013-May-31 20:14 UTC
Re: Getting json data to div and partial after ajax call?
Benjamin Iandavid Rodriguez wrote in post #1110828:> For what you say. > > After you get the JSON response the partial is already processed so you > just need to update the correct div with the correct info. > > Use jQuery''s append or html properties to update your divs. > > > 2013/5/31 Paul Bergstrom <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>I haven''t loaded the partial from start. Sorry but I don''t know how to update the div. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/21b4dda042298df3a784c58ae2b6bc56%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Paul Bergstrom
2013-May-31 20:57 UTC
Re: Getting json data to div and partial after ajax call?
I get an array back in json. That is loaded but without styling. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/add0e6ea9b0aa3138cfe66786df1413e%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Fernando Jesus
2013-Jun-06 19:13 UTC
Re: Getting json data to div and partial after ajax call?
Have u solve your problem? i have the same issue U_U -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/61388e3b60ac7b85abafbe13227eeb52%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Paul Bergstrom
2013-Jun-08 22:22 UTC
Re: Getting json data to div and partial after ajax call?
Fernando Jesus wrote in post #1111571:> Have u solve your problem? i have the same issue U_U but without > coffeeScriptSorry to say, but no I didn''t. Still looking. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e574659d6d40bb584524c189b11cc102%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Fernando Jesus
2013-Jun-10 17:26 UTC
Re: Getting json data to div and partial after ajax call?
Ok i found the solution: http://stackoverflow.com/questions/7195473/rails-3-why-is-my-postshow-view-showing-all-of-its-comments-database-data-in The problem is in the view perhaps you have it''s the = in the @comments.each tag. It is returning the result of each, which is the whole array. For example: irb> [1,2].each {|i| puts i } 1 2 => [1, 2] So: <%= @comments.each do |comment| %> Should simply be: <% @comments.each do |comment| %> I hope that works for you. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9f326cb7ff13278486419abc3331df81%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
John Davalos
2013-Jun-10 21:03 UTC
Re: Re: Getting json data to div and partial after ajax call?
i''m not sure what you mean by styled. json usually looks like this {user:{name:''fred'',age:65}}. what kind of styling did you want to apply to that? i''m guessing, but it sounds like you''re looking for html elements to be returned? typically after the request happens you can just use jquery''s .html() method to insert your json into the element: $(''.element'').html(json-data-returned-from-server) where .element is the class name used by the html tag you''re trying to insert your json. json is just a string so it''s will be hard to add styling other than a font size, and font color. On Mon, Jun 10, 2013 at 10:26 AM, Fernando Jesus <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Ok i found the solution: > > http://stackoverflow.com/questions/7195473/rails-3-why-is-my-postshow-view-showing-all-of-its-comments-database-data-in > > > The problem is in the view perhaps you have > > > it''s the = in the @comments.each tag. It is returning the result of > each, which is the whole array. > > For example: > > irb> [1,2].each {|i| puts i } > 1 > 2 > => [1, 2] > So: > > <%= @comments.each do |comment| %> > Should simply be: > > <% @comments.each do |comment| %> > > > I hope that works for you. > > -- > 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 unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/9f326cb7ff13278486419abc3331df81%40ruby-forum.com?hl=en-US > . > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAE%2BzMv8aauvb%2B_L3L4nXN2COSPYNRuGPNxEOR9-ZWv%3DCB%2BvpyQ%40mail.gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.