如何向 jquery 移动页面添加是/否对话框?

发布于 2024-11-30 17:00:42 字数 2207 浏览 2 评论 0原文

当我将 $(document).ready({alert('it is ready')}); 添加到 SiteMaster.master 页面上的脚本标记中并使用以下链接调用该页面时:http ://192.168.1.66:90/Reminder/test.aspx#DialogChangeTag.aspx 我不工作,直到我用http://192.168.1.66:90/Reminder/DialogChangeTag.aspx 链接。

我哪里出错了? DialogChangeTag.aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/TekContent.master" AutoEventWireup="true"
    CodeFile="DialogChangeTag.aspx.cs" Inherits="DialogChangeTag" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PageIdContent" runat="Server">
    <div data-role="page" id="delete_dialog" data-theme="b">
        <script type="text/javascript">
            $(document).ready(function () {
                alert("calis");
            }); 
        </script>
        <div data-role="content" data-theme="b">
            <h1>
                Delete Item?</h1>
            <p>
                Are you sure you want to delete this item?</p>
            <a href="#" class="delete-dialog-yes" data-role="button" data-theme="b">Yes</a>
            <a href="#" class="delete-dialog-no" data-role="button" data-theme="b">No</a>
        </div>
    </div>
</asp:Content>

测试.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/TekContent.master" AutoEventWireup="true"
    CodeFile="test.aspx.cs" Inherits="test" %>

<asp:Content ID="ContentPage" ContentPlaceHolderID="PageIdContent" runat="Server">
    <div data-role="page" id="pageTest">
        <div data-role="header" data-position="inline">
            <h1>
                TEST HEADER</h1>
        </div>
        <div data-role="content">
            <h2>
                TEST CONTENT</h2>
            <a href="DialogChangeTag.aspx" data-role="button" data-rel="dialog" data-transition="pop">
                Show Dialog</a>
        </div>
        <div data-role="footer" class="ui-bar" id="divFooterContainer">
            <h3>
                TEST FOOTER</h3>
        </div>
    </div>

When I added $(document).ready({alert('it is ready')}); into script tags on the SiteMaster.master page and called the page with this link: http://192.168.1.66:90/Reminder/test.aspx#DialogChangeTag.aspx I doesn't work until I called it with http://192.168.1.66:90/Reminder/DialogChangeTag.aspx link.

Where am I making mistake?
DialogChangeTag.aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/TekContent.master" AutoEventWireup="true"
    CodeFile="DialogChangeTag.aspx.cs" Inherits="DialogChangeTag" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PageIdContent" runat="Server">
    <div data-role="page" id="delete_dialog" data-theme="b">
        <script type="text/javascript">
            $(document).ready(function () {
                alert("calis");
            }); 
        </script>
        <div data-role="content" data-theme="b">
            <h1>
                Delete Item?</h1>
            <p>
                Are you sure you want to delete this item?</p>
            <a href="#" class="delete-dialog-yes" data-role="button" data-theme="b">Yes</a>
            <a href="#" class="delete-dialog-no" data-role="button" data-theme="b">No</a>
        </div>
    </div>
</asp:Content>

Test.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/TekContent.master" AutoEventWireup="true"
    CodeFile="test.aspx.cs" Inherits="test" %>

<asp:Content ID="ContentPage" ContentPlaceHolderID="PageIdContent" runat="Server">
    <div data-role="page" id="pageTest">
        <div data-role="header" data-position="inline">
            <h1>
                TEST HEADER</h1>
        </div>
        <div data-role="content">
            <h2>
                TEST CONTENT</h2>
            <a href="DialogChangeTag.aspx" data-role="button" data-rel="dialog" data-transition="pop">
                Show Dialog</a>
        </div>
        <div data-role="footer" class="ui-bar" id="divFooterContainer">
            <h3>
                TEST FOOTER</h3>
        </div>
    </div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红衣飘飘貌似仙 2024-12-07 17:00:42

可能是因为您的 jQuery Mobile 设置为与 AJAX 配合使用。 $(document).load() 仅当新页面加载到浏览器中时才会被调用。这意味着当您使用基于 AJAX 的页面时,$(document).load() 将不起作用。如果该页面仅使用 AJAX 加载,则展开 $(document).load() 即可解决该问题。解决此问题的更好方法是使用不引人注目的客户端代码。看一下 Backbone.js。

Probably because your jQuery Mobile is setup to work with AJAX. $(document).load() only gets called when a new page is loaded in the browser. This means $(document).load() won't work when you are working with AJAX based pages. Unwraping $(document).load() would solve it if that page is only loaded with AJAX. A better way of solving this problem is using unobtrusive client side code. Take a look at Backbone.js.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文