i am trying to make ajax call with model reveal in my application.
able to pass dynamic id in url but it reveals only last model (without ajax-call) on each click
i tried previous solution with ajax-all Reveal Modal is revealing last value in loop iteration Foundation-zurb issue
but i am not able to pass dynamic id in javasript file.
model reveal reference link:- https://codepen.io/sujayjaju/pen/akAYzP?editors=1010
current code reveals one model on each reveal click i tried last solution as well(url mentioned) but it doesn’t worked with ajax-call.
application.js
$(document).on('open.zf.reveal', "#exampleModal1", function (e) {
var $modal = $(this);
var ajax_url = $modal.data("ajax-url");
if (ajax_url) {
$modal.html("Now Loading: "+ajax_url);
$.ajax(ajax_url).done(function (response) {
$modal.html(response);
});
}
});
index.html.erb
<% @project.project_sites.where(submission_status: true).order("created_at desc").each do |project_site| %>
<tr>
<td><%= project_site.user.name %></td>
<td>
<div class="full reveal" id="exampleModal1" data-reveal data-ajax-url="http://0.0.0.0:3000/project_sites/<%= project_site.id %>/attendances/">
<button class="close-button" data-close aria-label="Close modal" type="button">
<span aria-hidden="true">×</span>
</button>
</div>
<p><button class="button small warning button-margin-top fi-eye" data-open="exampleModal1"> View</button></p>
</td>
</tr>
<%end %>
2
Answers
just found easy solution to this problem that worked:- (with internal jquery)
index.html.erb
You can refer this particular commit from my application which is well.
Javascript Code
HAML Code
My Links look like this
Some handy helpers that I use for reveal are
You can refer more helpers here