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?
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?
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 B. [email protected]
Benjamin Iandavid R. 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 B. [email protected]
I haven’t loaded the partial from start. Sorry but I don’t know how to
update the div.
I get an array back in json. That is loaded but without styling.
Fernando Jesus wrote in post #1111571:
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.
Have u solve your problem? i have the same issue U_U but without
coffeeScript
Ok i found the solution:
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.
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs