javascript - jquery的对话框模式可以改变模式内的页面吗?

标签 javascript jquery jquery-ui jquery-ui-dialog

您好,我尝试使 jquery 对话框弹出窗口(模态)可以更改为弹出窗口中的其他页面(在现有弹出窗口中加载其他页面)

但我不知道如何通过在 test2.php 中编码来加载模式内的 test3.php

这是我的尝试

test1.php

 <!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Dialog - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

</head>
<body>
 <button id="btn">Click to Popup</button>

<div id="dialog" title="Basic dialog">
  here 
</div>
 <script>
    $(function () {
        $("#dialog").dialog({
            open: function(event, ui) {
             $('#dialog').load('test2.php', function() {
               alert('Load was performed.');
             });
           },
            modal: true,
            autoOpen: false,
            title: "jQuery Dialog",
            width: 600,
            height: 350
        });

    $("#btn").click(function(){
        $('#dialog').dialog('open');
    });
    });
 </script>


</body>
</html>

test2.php

this is test2.php page <br/>
<a href="test3.php"> Go to Page test3.php </a>

test3.php

<p> this is test3.php page </p>

最佳答案

在 test1.php 中尝试一下

$(function () {
    $("#dialog").dialog({
        open: function(event, ui) {
        $('#dialog').load('test2.php', function() {
            $('#mylink').click(function(){
                $('#dialog').load('test3.php', function() {
                      alert('Load was performed.');
                });
             });
         });
       },
        modal: true,
        autoOpen: false,
        title: "jQuery Dialog",
        width: 600,
        height: 350
    });

    $("#btn").click(function(){
        $('#dialog').dialog('open');
    });
});

test2.php

this is test2.php page <br/>
<button id="mylink">Go to Page test3.php</button>

关于javascript - jquery的对话框模式可以改变模式内的页面吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41276136/

相关文章:

javascript - 在 html 页面中插入多项选择

javascript - 如何在Vuejs中插入Echarts?

javascript - 如何用JS播放声音?

javascript - 自动替换 JavaScript 中的大量内容字符串

javascript - 如何用jQuery获取子元素?

jquery - 内容动态化后,可拖动不再起作用

javascript - 如何遍历数组并将每次迭代写入同一个文件 [nodejs]

javascript - jQuery 获取所有复选框的数据属性到一个字符串

jquery-ui - jQuery-JTable:为行添加单击事件?

javascript - 如何使用 bootstrap 或 jquery UI 添加范围下拉列表