Hello!
You see ... I have a dilemma with the load of a file (view) that I need will be in the body
of a modal
, since, this will be the beginning to be able to show information later.
As such, I have the following.
In my view Listing (where I have a table of values) I've assigned it to display the button dynamically, which throws a modal
to show a file with values dynamically of the ID that has been selected (That is the goal) .
Before that, I was stuck with even showing the file that would load modal
.
I show you the 1st code of the button:
<button type="button" class="btn btn-success btn-view-contrato" value="<?php echo $NewContrato->id_contratos_d;?>" data-toggle="modal" data-target="#modal_contrato"><span class="fa fa-file-text-o"></span></button>
The code of modal
:
<div class="modal fade" id="modal_contrato">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title">Contrato</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger pull-left" data-dismiss="modal">Cerrar</button>
<button type="button" class="btn btn-primary btn-print"><span class="fa fa-print"> </span> Imprimir</button>
</div>
</div>
</div>
</div>
The script:
<script >
$(document).on("click",".btn-view-contrato", function(){
valor_IDcontrato = $(this).val();
$.ajax({
url: base_url + "clientes/Clientes_controller/contrato_view",
type:"POST",
dataType:"html",
data:{id:valor_IDcontrato},
success:function(data){
$("#modal_contrato .modal-body").html(data);
}
});
});
</script>
Watch out! Make sure the most logical thing is that the route was fine both to call the controller and call the file to load.
And finally, the function of the controller:
public function contrato_view(){
$New_id_Contrato = $this->input->post("id");
$this->load->view("admin/clientes/contrato");
}
But it does not load the view and only appears in white:
NOTE: I know that I am not passing information to the modality so far, but first of all I need to show the view that I am passing through to you until now ( $this->load->view("admin/clientes/contrato");
) since to pass information belonging, I manage passing a data
from a ARRAY
.
Thank you very much for reading this in the 1st instance: D