The Bootstrap modal dialog box for the front-end frame allows you to specify a URL using the remote option so that the dialog box will automatically load data from this address at the first pop-up to. Modal-body, but it will only be loaded once, but by invoking the The Removedata () method can solve this problem.
Bootstrap modals Dialog Hidden Removedata
Catalogue [-]
- 1. Bootstrap modal dialog box and simple use
- 2. Use the remote option to have the modal dialog box load the page into the. modal-body
- 2.1 Using Links
- 2.2 Using scripts
- 3. Remove the data so that the dialog box can reload the page each time it is opened
- Reference documents
1. Bootstrap modal dialog box and simple use
12345678910111213 |
<
div
id
=
"myModal"
class
=
"modal hide fade"
>
<
div
class
=
"modal-header"
>
<
button
type
=
"button"
class
=
"close"
data-dismiss
=
"modal"
>x</
button
>
<
h3
>对话框标题</
h3
>
</
div
>
<
div
class
=
"modal-body"
>
<
p
>对话框主体</
p
>
</
div
>
<
div
class
=
"modal-footer"
>
<
a
href
=
"#" class
=
"btn"
data-dismiss
=
"modal"
>取消</
a
>
<
a
href
=
"#"
class
=
"btn btn-primary"
data-dismiss
=
"modal"
>确定</
a
>
</
div
>
</
div
>
|
Display effects similar to:
Modal dialogs can be called directly using buttons or links, which is simple to use:
12 |
<
button
type
=
"button"
data-toggle
=
"modal"
data-target
=
"#myModal"
>打开对话框</
button
>
<
a
href
=
"#myModal"
role
=
"button"
class
=
"btn"
data-toggle
=
"modal"
>打开对话框</
button
>
|
This will only show the static content in the dialog box, using the Remote option of the dialog box to achieve a more powerful effect.
2. Use the remote option to have the modal dialog box load the page into the. modal-body
There are two ways to use a link, and the other is to use a script.
2.1 Using Links
1 |
< a href = "page.jsp" data-toggle = "modal" data-target = "#myModal" >打开对话框</ a > |
When this link is clicked, the contents of the page.jsp will be loaded into the. Modal-body dialog box.
2.2 Using scripts
123 |
$( "#myModal" ).modal({ remote: "page.jsp" }); |
The effect of this script is the same as using a link, and when the script executes, the contents of the page.jsp are loaded into the. Modal-body of the dialog box, and the dialog box appears.
Behind both methods, Bootstrap called the JQuery Load () method and loaded the page.jsp page from the server side. But this load will only happen once, no matter how many times you click the link, or execute a few scripts, even if you change the value passed to the Remote option, the dialog box will not reload the page, this is a very frustrating thing. But the problem can still be solved.
3. Remove the data so that the dialog box can reload the page each time it is opened
After searching and reviewing the relevant documents, it is possible to write a statement in the hidden event of the dialog box:
123 |
$( "#myModal" ).on( "hidden" , function () { $( this ).removeData( "modal" ); }); |
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:
123 |
$( "#myModal" ).on( "hidden.bs.modal" , function () { $( this ).removeData( "bs.modal" ); }); |
Http://my.oschina.net/qczhang/blog/190215?p=1
Bootstrap modal dialog box to load only one remote data solution