我正在尝试学习自己的 jQuery Mobile。我认为这真的很酷,但我被困在了一些事情上。如果我想这样称呼:
$j.mobile.changePage({ url: $j("#News"), data: "apple=banana", type: "GET"}, "slide", true, true);
它似乎不起作用。我不知道用 jQuery 传递数据,所以也许我做错了什么。
亲切的问候,森内
编辑:对不起,把错误的代码放在那里......
我正在尝试学习自己的 jQuery Mobile。我认为这真的很酷,但我被困在了一些事情上。如果我想这样称呼:
$j.mobile.changePage({ url: $j("#News"), data: "apple=banana", type: "GET"}, "slide", true, true);
它似乎不起作用。我不知道用 jQuery 传递数据,所以也许我做错了什么。
亲切的问候,森内
编辑:对不起,把错误的代码放在那里......
基于反复试验,这就是我看到的情况:
因此,似乎基本 URL 必须不同才能在服务器上执行时更新当前视图。
据我所知 - url 必须是真实的 url或另一个的 iddiv[data-role=page]
澄清:
提供 ID 会显示当前文档中可用的另一个 div(您可以创建包含多个页面的 html 文件)。
另外 - jquerymobile 只加载一次页面,并将其添加到文档中以供以后参考。以后不会触发任何服务器端操作。(我不确定它如何处理提供数据的调用)
I ran into a scenario where I needed to capture a tap event on an item and display a loaded page (same html file) with details for the tapped item. The solution I found is semi-dependent on a few things, however:
Attaching a tap event to the element causing the page transition (or even ina function causing a page transition problematically) allows you to create a function as follows:
function PageTransitionHandle(oEvent)
{
// Set your stored data to a global object
oYourNamespace.DataObject = oDataObject;
// not necissary if already linked to other page but useful when attaching to
// an image or other element
$.mobile.changePage("#otherPageId");
}
and in the pageshow event for the next page:
function PageInit()
{
var oPageData = oYourNamespace.DataObject;
// Handle using data from here (i.e calling webmethod using parameters
// or setting data according to object)
}
Potentially this should work with external pages and internal pages since ajax loading methods are used, but I have not tested. This is useful for passing parameters or even whole data objects to define other feilds, or letting a users information follow them, anything really.
Another route to look at is Local Storage but I haven't personally looked at this much yet