Opening Dialog from within a Dialog in JQuery Mobile - javascript

I am trying to open a Dialog from within a Dialog without Success.
Here is my html:
Delete page...
<div data-role="popup" id="popupDialog" data-overlay-theme="a" data-theme="c" data-dismissible="false" style="max-width:400px;">
<div data-role="header" data-theme="a" class="ui-corner-top">
<h1>Delete Page?</h1>
</div>
<div data-role="content" data-theme="d" >
<h3 class="ui-title">Are you sure you want to delete this page?</h3>
<p>This action cannot be undone.</p>
Cancel
<a data-role="button" data-rel="back" data-transition="flow" data-theme="b" onclick="NewDialog();">Open New Dialog</a>
</div>
</div>
<div data-role="popup" id="popupDialog1" data-overlay-theme="a" data-theme="c" data-dismissible="false" style="max-width:600px;">
<div data-role="header" data-theme="a" class="ui-corner-top">
<h1>Top Delete Page?</h1>
</div>
<div data-role="content" data-theme="d" >
<h3 class="ui-title">Dialog Called from A Dialog</h3>
<p>This action cannot be undone.</p>
Option-1
Option-2
</div>
</div>
And here is the a small js function:
function NewDialog()
{
//alert("Alert-1");
("#popupDialog1").popup("open");
}
Any idea how can I call the second dialog successfully?
JS Fiddle is here

You need to set the first popups second button which is the open new dialog to popup. And set its data-rel instead of data-rel="back" set it to data-rel="popup" and also provide a reference to what you want to popup which is the href --> href="#popupDialog1"
here's a Fiddle with a popup within popup --> http://jsfiddle.net/EWQ6n/520/
And btw you can remove the onClick event you have setup.

Related

Back button not loading page content - JQuery Mobile

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>

when text focus (keyboard open) the fixed header hide(gone)

In my phonegap application for android(4.2.2) using jquery mobile(v 1.3.2) when the text box is focused (keyboard is open/show) at the time the jquery mobile FIXED header hide never visible again.Here is the sample code.
<!-- header start -->
<div data-role="header" id="header" data-position="fixed" data-tap-toggle="false">
<h4>Stop Card</h4>
<div class="ui-btn-left">
<a data-role="button" data-icon="check" id="save" >Lagre</a>
</div>
<div class="ui-btn-right">
<a data-role="button" data-icon="delete" id="stopCardcancel" >Avbryt</a>
</div>
</div>
<!-- header end -->
Using this you can fix the header issue data-hide-during-focus="false". This will fix the header.
Try like this
<!-- header start -->
<div data-role="header" data-position="fixed" data-tap-toggle="false" data-hide-during-focus="false" data-transition="none">
<h4>Stop Card</h4>
<div class="ui-btn-left">
<a data-role="button" data-icon="check" id="save" >Lagre</a>
</div>
<div class="ui-btn-right">
<a data-role="button" data-icon="delete" id="stopCardcancel" >Avbryt</a>
</div>
</div>
<!-- header end -->
Note: Only in JQM 1.3.2
Looks the repository, is an open issue 'fixed toolbars unfix after softkeyboard #5556'
Perhaps this answer for another stackoverflow question can help you.
Some times data-position="fixed" will not work properly, so give position:fixed for ui-header class.
.ui-header
{position:fixed;}

jQuery mobile - panel style removed when loading from any page other than initial one

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

Jquery Mobile - jumping fixed header after closing dialog (firefox)

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>

Cannot show Popup with jQuery Mobile 1.3.1

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.

Categories