Home >Web Front-end >CSS Tutorial >How to Load Remote Data into Bootstrap 4 Modals?
Bootstrap 4 Modal Remote Data Loading
In the latest release of Twitter Bootstrap (v4 alpha), the ability to load remote content into a modal has been removed. This functionality existed in Bootstrap 3, but is no longer supported.
Problem
When attempting to use the data-remote attribute to load remote content into a modal in Bootstrap 4, the model body remains empty and no request is sent to the specified URL.
Solution
To resolve this issue, you can use JavaScript to manually load the remote content into the modal body. Here's an example:
$('body').on('click', '[data-toggle="modal"]', function(){ $($(this).data("target")+' .modal-body').load($(this).data("remote")); });
This code attaches an event listener to all elements with the data-toggle="modal" attribute. When one of these elements is clicked, it retrieves the data-remote value from the element and uses jQuery's .load() method to load the remote content into the modal body.
Note: The deprecated remote option has been removed in Bootstrap 4 and is recommended to be implemented using client-side templating, data binding frameworks, or by manually calling jQuery.load() as demonstrated above.
The above is the detailed content of How to Load Remote Data into Bootstrap 4 Modals?. For more information, please follow other related articles on the PHP Chinese website!