"Go" bootstrap Modal box (modal) load data using the remote method, only one solution can be loaded once

Source: Internet
Author: User

In Http://blog.csdn.net/coolcaosj/article/details/38369787bootstrap's modal, there is a remote option to dynamically load pages into modal-body in two ways, One is to use a link, and the other is to use a script.

1 Using Links
<a href= "user/userdetail.jsp" data-toggle= "modal" data-target= "#myModal" > Open dialog Box </a>

When you click on the connection, the contents of the userdetail.jsp can be dynamically loaded into the div.modal-body. Of course, the connection here can also be an action

2 Using scripts

[JavaScript]View Plaincopyprint?
    1. $ ("#myModal"). Modal ({
    2. Remote: "page.jsp"
    3. });


But after this load, there will be problems, modal data is loaded only once, if you want to load different data, for example, according to the ID to query the details of different items, modal data can not be updated, even if the ID value is different. In fact, the solution is very simple, just need to load the data before the next time to clear the previous loaded data.

Clears previously loaded data so that the dialog can reload the page each time it is opened

The simplest way is to listen to the hidden of the modal, and when the modal is turned off, the data is erased:

[JavaScript]View Plaincopyprint?
    1. $ ("#myModal"). On ("hidden", function () {
    2. $ (this). Removedata ("modal");
    3. });


You can also remove the data before you open the dialog box, the effect is the same.

Note: The above code is based on Bootstrap v2, if you use Bootstrape v3, the modal dialog's HTML and event notation are somewhat different, for example, for the above hidden event, write:

[JavaScript]View Plaincopyprint?
    1. $ ("#myModal"). On ("Hidden.bs.modal", function () {
    2. $ (this). Removedata ("Bs.modal");
    3. });

Reference: http://blog.csdn.net/a657941877/article/details/18145023

"Go" bootstrap Modal box (modal) load data using the remote method, only one solution can be loaded once

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.