I need to know, how to fetch class name from div instead of id when using Ajax on Rails
my coding is like below,
<div id="test_test1" class="test">
</div>
<div id="test_test2" class = "test">
</div>
and on Controller,
page.replace_html "test_test1", "<button>Thanks</button>"
please help me to solve this problem.
Thanks
If you want replace values of all divs with class ‘test’ you can use from rjs this code
If only one of them – then you shouldn’t do it from rjs because of class of dom element not unique. You can use link_to_remote callbacks. See docs here – http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001645