Someone has to know how to do this

I’ve got my site posting comments with ajax, but I can’t seem to handle
the callback correctly.

Do I just put what I want returned in the “comments.rhtml” file? I’ve
been trying to do this, but am having no luck.

If I have the parameters for the comments, I should be able to single
them out, but I’m not sure how to do it. This is what I mean:

<%=params[:comments]%> #returns name, site, comment, but not
individually.

How can I do this essentially (without getting errors),

<%=params[:comments.name]%>
<%=params[:comments.site]%>
<%=params[:comments.created_at]%>
<%=params[:comments.entry]%>

Also, when I try to use strftime in “comments.rhtml” it says that it’s
undefined.

I don’t even know if the above things that I mentioned are even the
right way to go about it, I just don’t know how to do it.

The comments are saving to the database fine, but I have to refresh the
page to get it to show up. Also, I would like to use
“Effect.Appear(‘new-comment’)” oncomplete. This doesn’t seem to be
working either.

Can someone tell me how to display the comment after an Ajax submission?

Please HELP!

Thanks!

On Thu, 2006-03-16 at 17:01 +0100, ryan wrote:

individually.

How can I do this essentially (without getting errors),

<%=params[:comments.name]%>
<%=params[:comments.site]%>
<%=params[:comments.created_at]%>
<%=params[:comments.entry]%>


I would think that these should be…

<%= params[:comments][:name] %>
<%= params[:comments][:site] %>
<%= params[:comments][:created_at] %>
<%= params[:comments][:entry] %>

Also, when I try to use strftime in “comments.rhtml” it says that it’s
undefined.


you should probably show how your using it but I would think that this
should work…

<%= (params[:comments][:created_at]).strftime("%m/%d/%Y") %>

I don’t even know if the above things that I mentioned are even the
right way to go about it, I just don’t know how to do it.

The comments are saving to the database fine, but I have to refresh the
page to get it to show up. Also, I would like to use
“Effect.Appear(‘new-comment’)” oncomplete. This doesn’t seem to be
working either.

Can someone tell me how to display the comment after an Ajax submission?


I’ll let someone else help with that.

Craig

I THINK CRAIG NAILED IT ON THE HEAD RYAN !
THANKS CRAIG. MY CAPSLOCKS KEY MUST BE STUCK :smiley:

Dylan S. wrote:

I THINK CRAIG NAILED IT ON THE HEAD RYAN !
THANKS CRAIG. MY CAPSLOCKS KEY MUST BE STUCK :smiley:

Yes, I can access the name, site, and entry that way, but not the
“created_at” attribute.

How can I access this variable? I guess since it’s automatically
created, it doesn’t show up in the params?

Also, how can I return a count one more than the last comment?
Essentially, displaying #1, #2, #3 with each comment.

Right now, on page load, I’m incrementing a counter inside of the for
loop which iterates through the comments, but since I’m trying to do
ajax, this part won’t be involved in the for loop.

please help again!

OK - I will bite, even if you posted the topic in caps.

The return from the AJAX call will need to update a div in your page.
Try to get it working by just returning
render_text ‘done’. When you see your page updating the div with ‘done’
you can then try returning the actaully content that you want displayed.

I find the best way to do this is using a partial. To illustrate, here
is an AJAX action from the app that I am currently working on.

def set_priority
requirement = Requirement.find( params[:id] )
requirement.increment_priority
requirement.save
vendors = Vendor.find( :all )
render :partial => “requirements”, :locals => { :requirement =>
requirement, :vendors => vendors }
end

and here is the the rhtml from the original page.

<% for feature in @features %>
<% requirement = feature.requirement( @project.id) %>
<%= render( :partial => “requirements”, :locals => { :requirement =>
requirement, :vendors => @vendors } ) %>
<% end %>

Hope this helps.