2011-04-12 34 views
0

我的母版頁是這樣的:視圖是空白的,即使螢火蟲看到HTML

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <link rel="stylesheet" href="../../Content/CSS/jquery.mobile-1.0a4.1.min.css" /> 
    <script src="../../Scripts/jquery-1.5.1.min.js"></script> 
    <script src="../../Scripts/jquery.mobile-1.0a4.1.min.js"></script> 

    <title>Test</title> 
</head> 
<body> 
    <div> 
     <asp:ContentPlaceHolder ID="MainContent" runat="server"> 

     </asp:ContentPlaceHolder> 
    </div> 
</body> 
</html> 

而我的看法是這樣的:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Mobile.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> 

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server"> 
    <p>Hello from Mobile Land</p> 
</asp:Content> 

螢火顯示了這個作爲HTML:

<html xmlns="http://www.w3.org/1999/xhtml" class="ui-mobile ui-mobile-rendering landscape ui-loading min-width-320px min-width-480px min-width-768px min-width-1024px"><head><meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1"><base href="http://localhost:2189/Home/MobileHome"><link href="../Content/CSS/jquery.mobile-1.0a4.1.min.css" rel="stylesheet"> 
    <script src="../../Scripts/jquery-1.5.1.min.js"></script> 
    <script src="../../Scripts/jquery.mobile-1.0a4.1.min.js"></script> 

    <title> 
    Test </title></head> 
<body> 
    <div> 

    <p>Hello from Mobile Land</p> 

    </div> 


</body></html> 

所以我想弄清楚爲什麼我在屏幕上看不到任何東西?

+0

我認爲你使用的是jQuery mobile?你在看什麼網站?個人電腦,移動設備等? jQuery mobile使用Ajax顯示大量內容,您是否檢查過正在創建的Ajax請求以及返回的內容? – timothyclifford 2011-04-12 03:27:41

+0

我假設meta,base和link標籤正確關閉,並且那個螢火蟲正在省略/>? – 2011-04-12 03:45:19

回答

0

JQuery mobile需要將所有HTML標記包含在data-role屬性中,否則將不會呈現它們。

移動頁面的解剖結構是這樣的:

<div data-role="page"> 
    <div data-role="header">...</div> 
    <div data-role="content">...</div> 
    <div data-role="footer">...</div> 
</div> 

如果你把你的<p>標籤像上述範圍內,它會工作。這就是JQuery手機如何構建頁面。如果您包含Mobile腳本,則每次都會嘗試並執行此操作。