I'm trying to pop up a very simple "are you sure?" popup in jQuery Mobile. But if I use the data-rel="popup" on the button, nothing happens. If I remove the data-rel it opens - but as a full window. The logic works well, but still, I'd like to see a popup.
Here's the code (simplified - I removed the other pages, the header, html etc. - the app works well other than this issue, so no need to debug those). The 2 elements to look at are the button "clearHistory" and the popup itself "history":
<!-- history page -->
<div data-role="page" id="history">
<div data-role="header" data-position="fixed">
Back
<h1>History</h1>
Delete
</div><!-- /header -->
<div data-role="content">
<ul data-role="listview" id="historyList" data-inset="true" data-theme="f"></ul>
<h4 id="historyEmpty">History is empty</h4>
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
<h4><a class="ttg" href="http://www.TravelingTechGuy.com" rel="external" target="_blank">Traveling Tech Guy</a></h4>
</div><!-- /footer -->
</div>
<!-- end history page -->
<!-- delete history popup -->
<div data-role="popup" id="deletePopup" data-overlay-theme="a" data-theme="c" data-dismissible="false">
<div data-role="header" data-theme="a">
<h1>Delete History?</h1>
</div>
<div data-role="content" data-theme="d">
<h3>Delete all items in history?</h3>
Cancel
Delete
</div>
</div>
<!-- delete history popup -->
Any idea what am I missing here?
Place popup inside <div data-role=page> and that div should be the direct parent of popup div. I placed before <div data-role=content> in the below demo.
Demo
Dialog should be placed outside <div data-role=page> because they are treated as a page.
Related
I have a jQuery Mobile page (Fiddle here) which loads an external footer like so:
<!-- Start of universal footer -->
<div data-role="footer" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar">
<ul>
<li>One</li>
<li>Two</li>
</ul>
</div>
</div>
<!-- /End of universal footer -->
<!-- Start of first page -->
<div data-role="page" id="tabOne">
<div data-role="header">Page 1</div>
<div role="main" class="ui-content">Content</div>
</div>
<!-- /End of first page -->
<!-- Start of second page -->
<div data-role="page" id="tabTwo">
<div data-role="header">Page 2</div>
<div role="main" class="ui-content">Content</div>
</div>
<!-- /End of second page -->
With some js:
$(function() {
$("[data-role='navbar']").navbar();
$("[data-role='footer']").toolbar({theme: "a"});
});
This is all working perfectly, but I'd like to have another page (a login page which displays first) which doesn't show the footer (or shows an alternate one) but I can't seem to make that happen. Any ideas?
I am building a hybrid app on jquery mobile and i wanna use back buttons to navigate between different pages.
I have created the back button and it DOES load the url of the last page, but it doesn't refresh the page content (it keeps showing the same page ie: the button doesn't realize the function)
Looking through the questions previously asked about back button - jquery mobile I can't find one exposing a problem of page loading (cause as I said the button gets the right url but doesn't load the page content)
NOTE: i am using IBM Mobile First
<a href="#loginPage" data-direction="reverse" data-role="button"
id="mainPageBackBtn" data-icon="back" data-iconpos="notext"
data-corners="false">Button</a>
(I wanna move from main page --> login page)
Your HTML button tag is working fine in JSfiddle:
https://jsfiddle.net/pengyanb/a8pzr7gt/6/
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.css" rel="stylesheet"/>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
<div data-role="page" id="mainPage" data-theme="a">
<div data-role="header" data-position="fixed">
<a href="#loginPage" data-direction="reverse" data-role="button"
id="mainPageBackBtn" data-icon="back" data-iconpos="notext"
data-corners="false">Button</a>
<h5>Main Page</h5>
</div>
<div data-role="main" class="ui-content">
<h2>This is Main Page</h2>
</div>
</div>
<div data-role="page" id="loginPage" data-theme="a">
<div data-role="header" data-position="fixed">
<a href="#mainPage" data-direction="reverse" data-role="button"
id="mainPageBackBtn" data-icon="back" data-iconpos="notext"
data-corners="false">Button</a>
<h5>Login Page</h5>
</div>
<div data-role="main" class="ui-content">
<h2>This is Login Page</h2>
</div>
</div>
Maybe try check you tag Id is correctly assigned?
You can try using data-ajax="false" here:
<a href="#loginPage" data-ajax="false" data-direction="reverse" data-role="button"
id="mainPageBackBtn" data-icon="back" data-iconpos="notext"
data-corners="false">Button</a>
I have a jQuery mobile site with 2 pages loaded into one html file that use the same panel, which is also in the file, just outside of all the data-rol="page" divs. The problem is when you reload the second page, as in visit before using the first page, the jQuery mobile styling on the ul in the panel is gone.
I've tried adding enhanceWithin() to the code after creating the panel but I must be missing something, it's loading the same panel, how is the style lost if reloaded from another page?
Source
<div data-role="page" class="ui-responsive-panel" data-theme="b" id="page">
<div data-role="header" data-position="fixed">
<h1>Alpha</h1>
Menu
</div><!-- /header -->
<div data-role="content">
<h1>News and Features</h1>
<a href="#page2"><p>Lorem ipsum</p>
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
<p>Content TBD</p>
</div>
</div>
<div data-role="page" class="ui-responsive-panel" data-theme="b" id="page2">
<div data-role="header" data-position="fixed">
<h1>Alpha</h1>
Menu
</div><!-- /header -->
<div data-role="content">
<h1>News and Features</h1>
<a href="#page"><p>Lorem ipsum</p>
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
<p>Content TBD</p>
</div>
</div>
and script:
<script type="text/javascript">
var panel = '<div data-role="panel" id="left-panel" data-position="right" data-display="push"><h1>Panel</h1><ul data-role="listview" data-theme="b"><li>test</li><li>test2</li></ul></div>';
$(document).one('pagebeforecreate', function () {
$.mobile.pageContainer.prepend(panel);
$("#left-panel").panel();
});
</script>
Edit: This is weird to explain, so if you visit the first page, id=page the menu loads up with the traditional jQuery mobile styling. If you navigate to the second page(id=page") after starting on that first page, the styling is fine. IF you, now on id="page2" hit the 'reload' button on your browser the style for the panel is gone, and it remains gone if you navigate back to id="page". So unless the first page is the starting point, the style is never applied, does that make sense?
On load of the second page use:
.trigger('create');
Use this to recreate panel on page 2.
More Here:
Reference
i have a problem, you can see that here (with firefox) : http://fiddle.jshell.net/ckuskun/qrcdS/show/light/
when click to "open" link, a dialog is opening. after closing this dialog, fixed header is jumping to the top.
how can i fix this problem
i'm having this problem mac firefox and windows firefox, no problem with other browsers. I have tried both as local and hosting.
http://www.screenr.com/BVhH
This is a jQuery Mobile bug and it is related to dialog's and how framework is handling page back action.
For now it can be fixed if you remove data-position="fixed" from a first page header.
Working example: http://jsfiddle.net/A5Tp8/5/embedded/result/
HTML :
<div data-role="page" id="yonetim">
<div data-role="header" id="fheader">
<h1>lorem</h1>
</div><!--header-End-->
<div data-role="content">
<a href="#yeni-kullanici-ekle" data-prefetch="true" data-theme="a" data-icon="plus" data-iconpos="right" data-rel="dialog" data-transition="pop" >open</a>
</div><!--content-End-->
<div data-role="footer" data-position="fixed" style="border-top:1px solid #aaa;">
<h6 id="footer-text"><a href="<?=BASE_URL; ?>/Anasayfa/CikisYap/" data-ajax="false" >log-out</a> - </h6>
</div><!--footer-End-->
</div><!--page-End-->
<div data-role="dialog" id="yeni-kullanici-ekle" data-theme="a">
<div data-role="header" data-theme="a">
<h1>Yeni Kullanıcı</h1>
</div>
<div data-role="content" data-theme="a">
deneme
</div>
<div data-role="footer" data-theme="a">
deneme
</div>
</div>
I realise that 1.3 is still a beta realise but was wondering if anyone is having the same issue as myself and solved it.
For the panels to work the page content must be contained within the data-role="content" container.
However, I am using some API's like twitter which call up content into data-role="content" container, and I also have ad tags in the container. Both of these use javascript and both disable the jQuery mobile platform. I can only get either of these features running in the platform with panels enabled from the first data-role="header" container.
Here is an example of my code that is failing. Thanks.
<div data-role="page" class="ui-responsive-panel">
<div data-role="header">
<h1>Title</h1>
</div><!-- /header -->
<div data-role="content">
<script language="javascript">
<!--
document.write('<scr'+'ipt language="#"></scri'+'pt>');
//-->
</script>
</div><!-- /content -->
<div data-role="footer">
footer text
</div><!-- /footer -->
<div data-role="panel" data-display="reveal" id="nav-panel">
<ul data-role="listview">
<li>link</li>
<li>link</li>
</ul>
</div><!-- /panel -->
</div><!-- /page -->
A panel should appear just after the page div, like this
<div data-role="page">
<div data-role="panel" id="mypanel">
<!-- panel content goes here -->
</div><!-- /panel -->
<!-- header -->
<!-- content -->
<!-- footer -->
</div><!-- page -->
You should place the panel code above the header directly under the page div..