I am implementing several modal windows through Bootstrap. One for each different thing. I have done the test to load different data in the same modal window.
I explain ...
I have one to pick up favorite users, another for followers and another for users I follow.
I have done the test for when I press the indicated button for any of the data I want, I open the same modal, but with the difference that they bring me data according to the button I press, be it favorites, followers and Following. Everything is going very well.
These data I bring from the BD through ajax (Jquery) and PHP.
What is the problem?
Make different HTML elements appear according to the link that I click on.
Example:
When I click on the Favorites link I would like a textbox to come out, but when I click on the Followers link I do not want the textbox. Knowing that this data (Followers, Favorites, Following) will open the same modal.
Maybe they can understand me.
$(document).ready(function(){
$('#multi_opt_user').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var recipient = button.data('whatever')
var modal = $(this)
modal.find('.modal-title').text(recipient)
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<a href="#" data-toggle="modal" data-target="#multi_opt_user" data-whatever="Personas que me siguen." class="add_more" id="add_more_to">Seguidores</a>
<a href="#" data-toggle="modal" data-target="#multi_opt_user" data-whatever="Mis favoritos." id="makeagifttosomeone">
<i class="fa fa-gift" aria-hidden="true"></i><br>
<span class="sp_style">Favoritos</span>
</a>
<div class="modal fade" id="multi_opt_user" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<i class="fi-heart"></i>
<button id="pethatlimypro" type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"></h4>
<div class="modal-body">
<div id="pocos"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>