I have a button that calls a modal
screen, passing the ID of the record in question.
I would like to know how to retrieve the data of this ID, at the moment that I display the Modal, so that I can bring the data on the screen?
Modal:
echo '<td><a href="#modal-editar" style="margin-right: 1%" class="btn btn-info tip-top" data-toggle="modal" chamada="'.$r->idChamada.'" title="Editar Valores da Chamada"><i class="icon-pencil icon-white"></i></a></td>';
Modal Structure:
<!-- Modal -->
<div id="modal-editar" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<form action="<?php echo base_url() ?>chamadas/adicional/editar" method="post" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h5 id="myModalLabel">Editar Chamada - Valores</h5>
</div>
<div class="modal-body">
<input type="hidden" id="idChamada" name="idChamada" value="" />
<table class="table table-bordered ">
<tr>
<td style="text-align: right; width: 200px"><strong>CLIENTE</strong></td>
<td>SAPORITI DO BRASIL LTDA</td>
</tr>
<tr>
<td style="text-align: right; width: 200px"><strong>DATA DA CHAMADA</strong></td>
<td>10/01/2015</td>
</tr>
<tr>
<td style="text-align: right; width: 200px"><strong>FUNCIONÁRIO</strong></td>
<td>JOÃO DA SILVA STATUS</td>
</tr>
<tr>
<td style="text-align: right; width: 200px"><strong>VALOR EMPRESA</strong></td>
<td><input type="number" name="dataInicial" value="10.00" class="span3"></td>
</tr>
<tr>
<td style="text-align: right; width: 200px"><strong>VALOR FUNCIONÁRIO</strong></td>
<td><input type="number" name="dataInicial" value="5.00" class="span3"></td>
</tr>
</table>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancelar</button>
<button class="btn btn-danger">Editar Valores</button>
</div>
</form>
</div>
Jquery
$(document).ready(function(){
$(document).on('click', 'a', function(event) {
var chamada = $(this).attr('chamada');
$('#idChamada').val(chamada);
});
});