Answer the question
In order to leave comments, you need to log in
How to asynchronously load data into a modal window?
Hello.
There are two controller actions: a list of computers and information from another table by computer id.
Here is a piece from the view:
foreach ($comps as $comp) {
echo "<tr><td><a href=\"#myModal\" data-toggle=\"modal\">".$comp->name."</a></td></tr>";
}
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<!-- Заголовок модального окна -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Заголовок модального окна</h4>
</div>
<!-- Основное содержимое модального окна -->
<div class="modal-body">
Содержимое модального окна...
</div>
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
When you click on the button to open the window, first go to the server for data, then replace the contents of the modal window with the text received from the server, and only then show it.
The link can be immediately transferred to the button properties through the data-attribute. For example like this:
Then, using js, catch a click on the '[rel=toggle-modal]' selector, pull out the link through $(this).data('url') and continue according to the plan.
How to catch a click, make a get request to the server, find a modal window by id and cause it to be displayed programmatically, google it yourself.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question