samedi 27 décembre 2014

Jquery : How to Varying modal content based on trigger button


Is there another way to varying modal with Picture based on trigger button?


If I have the trigger button which contains the picture:



data-picture="<?php echo $user->getPicture(); ?>"


What's the best approach to fetch and show the picture on the modal?


This is my picture field in that modal:



<div class="modal-body">
<center>
<img src="**(SHOULD I PUT THE PICTURE IN HERE?)**" name="picture" width="140" height="140" border="0" class="img-circle">
</center>
</div>


And this is the javascript who handle the modal :



<script type="text/javascript">
$('#ViewModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var picture = button.data('picture')

var modal = $(this)
modal.find('.modal-body img[name="picture"]').val(picture)
})

</script>




Aucun commentaire:

Enregistrer un commentaire