Sae Us
Sae Us

Reputation: 277

Bootstrap Modal only load div when clicked

Im using Bootstrap on a website where a page has a few modals.

Using Chrome Dev Tools i was testing the network usage and noticed that the images in the modal view are called/pre-loaded when the page loads - I guess that makes sense they are all in divs on a single page.

So my question is it possible to avoid that div from running only until the actual link to a particular modal is clicked?

Thanks.

Upvotes: 2

Views: 984

Answers (1)

mccannf
mccannf

Reputation: 16659

Use $.get or $.load in the click event handler of the button to display the modal.

Note that the HTML data you load via this ajax technique must be in the right bootstrap modal template.

See this gist here

Upvotes: 2

Related Questions