samedi 18 avril 2015

No data displayed in Twitter Bootstrap Modal php

I want to display page as a modal instead of redicting.Now my problem is, I can display the table inside modal but none of the supposed data is in it.My template looked like this..



<td><a class="btn btn-small btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="<?php echo getApplicantDetailsModals($l['Applicants']['id'],$l['Applicants']['lastname'],$l['Applicants']['firstname']) ?>">Name here</a></td>

<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="memberModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="memberModalLabel">Borrower Last 5 Loans Details</h4>
</div>
<div class="ct"></div>
</div>
</div>


where getApplicantDetailsModals is a helper that will point to a template


//helper



function getApplicantDetailsModals($id, $lastname, $firstname) {
$user = sfContext::getInstance()->getUser();
if($user->hasCredential('VIEW_APPLICANT')) {
$controller = sfContext::getInstance()->getController();
$url = $controller->genUrl(array(
'module'=>'misc',
'action'=>'applicant',
'id'=>$id
));
return "<span class='info'><a href='$url'>$lastname, $firstname</a></span>";
} else {
return "$lastname, $firstname";
}


}


and the template I want to show as a modal



<?php include_component('misc','applicant')?>
<table>
<tr>
<td>name</td>
</tr>
<?php foreach($applicant as $a):?>
<td><?php echo $a->name ?></td>
<?php endforeach ?>
</table


and lastly my js



<script type="text/javascript">
$('#exampleModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget) // Button that triggered the modal
// var recipient = button.data('whatever') // Extract info from data-* attributes
var modal = $(this);
var dataString = 'id' //+ recipient;

$.ajax({
type: "GET",
url: "<?php echo url_for('misc/applicant') ?>",
data: dataString,
cache: false,
success: function (data) {
console.log(data);
modal.find('.ct').html(data);
},
error: function(err) {
console.log(err);
}
});
})


This is a working app until I decided to use modal,now it will only display my table minus the expected data inside in it.I am new to JavaScript/ajax and maybe my JavaScript script is not working.Any help is appreciated


Aucun commentaire:

Enregistrer un commentaire