JQuery Mobile + web2py presents unique challenge because JQuery Mobile 
takes over control after server side. One issue I had was with redirections 
which does not work properly in this environment. JQuery Mobile recognized 
this and added an option how to make this working properly by returning 
your page div with a *data-url* attribute already specified. When you do 
this, jQuery Mobile will use that attribute's value for updating the URL, 
instead of the url used to request that page.


<body> 
<div data-role="page" data-url="docs/pages/docs-links-urltest/">

If this attribute is set from web2py the redirection will work properly 
(right now it adds a hash '#', which creates a lot of issues.

here is example of the page I got from jQuery Mobile documentation. If 
there is a way to change data-url dynamically from web2py when the page is 
generated the redirection will work properly. Additionally it needs to have 
a trailing slash.

How to do that in web2py?

Regards,
--Constantine

<!DOCTYPE html> 
<html> 
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<title>jQuery Mobile Framework - Test URL Example</title> 
<link rel="stylesheet" 
 href="//code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />  
<link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
<script src="//code.jquery.com/jquery-1.6.4.js"></script>
<script 
src="../../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
<script src="../../_assets/js/jqm-docs.js"></script>
<script 
src="//code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
</head> 
<body> 

<div data-role="page" data-url="docs/pages/docs-links-urltest/">
 <div data-role="header" data-theme="f">
 <h1>URL Test Page</h1>
 </div>
 <div data-role="content">
 <p>This is a regular page that updated the url with a different value than 
was requested.</p>
 </div>
</div>


</body>
</html>

http://jquerymobile.com/demos/1.0/docs/pages/page-links.html

Redirects and linking to directories

When linking to directory indexes (such as href="typesofcats/" instead of 
href="typesofcats/index.html"), you must provide a trailing slash. This is 
because jQuery Mobile assumes the section after the last "/" character in a 
url is a filename, and it will remove that section when creating base urls 
from which future pages will be referenced.

However, you can work around this issue by returning your page div with a 
data-url attribute already specified. When you do this, jQuery Mobile will 
use that attribute's value for updating the URL, instead of the url used to 
request that page. This also allows you to return urls that change as the 
result of a redirect, for example, you might post a form to "/login.html" 
but return a page from the url "/account" after a successful submission. 
This tool allows you to take control of the jQuery Mobile history stack in 
these situations.

Reply via email to