[Rails] Re: Getting json data to div and partial after ajax call?

2013-06-10 Thread Fernando Jesus
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.




Re: [Rails] Re: Getting json data to div and partial after ajax call?

2013-06-10 Thread John Davalos
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 li...@ruby-forum.comwrote:

 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+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.




[Rails] Re: Getting json data to div and partial after ajax call?

2013-06-08 Thread Paul Bergstrom
Fernando Jesus wrote in post #571:
 Have u solve your problem? i have the same issue  U_U but without
 coffeeScript

Sorry 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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.




[Rails] Re: Getting json data to div and partial after ajax call?

2013-06-06 Thread Fernando Jesus
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.




[Rails] Re: Getting json data to div and partial after ajax call?

2013-05-31 Thread Paul Bergstrom
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 li...@ruby-forum.com

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.




[Rails] Re: Getting json data to div and partial after ajax call?

2013-05-31 Thread Paul Bergstrom
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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.