I am working with ruby on rails (rails 4.2). Given a validation done in javascript I need to run a ruby tag or not. I found something similar here but it didn't work for me.
html:
<div id="consent"> //this is the code that sholuld put with //render partial: 'consent', :locals => {:text_consent => foo, :title => 'Title'} %> </div>
Javascript:
$(document).on 'click', '#next_page', (event) -> event.preventDefault() $("#consent").append('<%= render partial: \'consent\', :locals => {:text_consent => foo, :title => \'Title\'} %>') return
this is the content of the partial:
<div class="well well-sm"> <div class="p-3 mb-2 bg-warning text-dark"> <p class="text-warning h1 text-center"><%= title %></p> <p class="h4"><%= text_consent %></p> <div class="cotainer" style="text-align:center; vertical-align:middle;"> <%= check_box_tag 'accept_consent', '0', false, :style => "width: 50px; height: 50px;" %> </div> </div> </div>
Como resultado obtengo esto en el html (as a string):
<div id="consent"> "<%= render partial: \'consent\', :locals => {:text_consent => foo, :title => \'Title\'} %>" </div>
I know that ruby and javascript are two executions in different environments, but is there any way to do something like this or similar?
_consent.html.erb
)?