I'm using escape_javascript in a js.erb file in order to load a partial with AJAX :
$("#datas-user").html("<%= escape_javascript(render :partial => '/pro/users/show_partial', :locals => { :id => @user.id }) %>");
My issue is that the javascript used in my partial seems to be broken?
In my view, I have a button id="relation-contact-button" using jQuery Hide function to show a div loaded in display: none
my partial :
<div class="row">
<div class="col-xs-7">
<div class="user_name"><%= @user.firstname %> <%= @user.lastname.chr %>.</div>
</div>
<div class="col-xs-5">
<div id="relation-contact-button" class="btn btn-blue">Contact</div>
</div>
</div>
<div id="relation-contact" class="rows">
<div class="col-xs-12 col-lg-12">
<%= form_for :message, url: pro_messages_path do |f| %>
<%= f.label :message, :class => "search-title" %>
<div class="form-group">
<%= f.text_area :message, :rows => 2, :class => "form-control", :placeholder => "Expliquez ce que vous pouvez apporter à cette personne" %>
</div>
<%= f.hidden_field :user_id, :value => @user.id %>
<%= f.submit "Envoyer", :class => "btn btn-blue" %>
<% end %>
</div>
</div>
my css :
#relation-contact {
display: none;
}
my js :
$("#relation-contact-button").click(function(){
$('#relation-contact').show();
});
When I use the same code without the partial it works, with it nothing happens.
Is there a way to render my partial and keep my js working?
Thanks a lot.
F