Ruby on Rails Thursday, June 15, 2017



On Thursday, June 15, 2017 at 5:11:29 PM UTC-4, Walter Lee Davis wrote:
If you are doing this in a RJS template, then you will have the instance variables available to you, whatever you set at the controller that is rendering this. Just render the form using the @comment you created in the controller.

I just posted an answer to a different question you raised, where I show you how to get the unique IDs on the DOM elements holding members of a collection. You can use that technique with RJS or with a single JS file that does not have any ERB replacement in it.

Walter

> On Jun 15, 2017, at 4:23 PM, fugee ohu <fuge...@gmail.com> wrote:
>
> This is my jquery
> $('.new_comment_button').after("<%= j render('form') %>");
> I need
> $('.new_comment_button') to be contructed from the values of variables because i can't give every post the same id I don't think using class instead of id in my view would make a  difference How can i do this?
>
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/941f357b-b82a-4e27-82b4-1effb5303d12%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Can I have the link And once I get the DOM id's how do i plug them into my js.erb file to change $('.new_comment_button') to let's say  $('.new_comment_button2') 

--
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@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/c5c586c2-70f7-452c-86af-b2e247482464%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment