如何向 jquery 移动页面添加是/否对话框?
当我将 $(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能是因为您的 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.