JQM pagecontainer change redirects back to home page automatically - jquery-mobile

I am working with a single page model
JQM version 1.4.5
platform XDK
I want to navigate from SignInPage to SignUpPage on Click as follows;
<!-- pageOne -- Sign In -->
<div data-role="page" id="signInPage" class="blue">
<div data-role="content" class="ui-content formContents" style="padding: 15px;">
<img border="0" src="images/login_icon.png" class="centerimg" >
<form id="loginform">
<input type="text" placeholder="User Name" id="loginusername">
<input type="password" placeholder="Password" id="loginpassword">
<input type="submit" value="login" data-theme="a" id="loginBtn">
</form>
</div>
</div>
<!-- pageTwo -- Sign Up -->
<div data-role="page" id="signUpPage" class="blue">
<div data-role="content" style="padding: 15px" class="formContents">
<img border="0" src="images/login_icon.png" class="centerimg">
</div>
</div>
and the corresponding JS code
$(document).on('pageinit','#signInPage', function(){
$('#loginBtn').on('click',function() {
$.mobile.changePage( "#signUpPage", { transition: "slideup"} );
// redirectRegister();
});
});
function redirectRegister(){
$.mobile.pageContainer.pagecontainer('change', '#signUpPage', {
"transition" : "slide"
});
return false;
}
As you can notice i tried both pageContainer and changePage methods and both gives me the same behaviour, goes to next page then redirect automatically to home again
I checked these solutions and non of them worked for me;
pagecontainer solution
change page solution
Does anyone have an idea about what is going on exactly or how to trace what's going on while trying to change page and he auto redirection to home

Related

scrollbar won't go away in jquery mobile

I'm using jQuery Mobile and no matter how much content is on the page there is always a scrollbar that appears to the right. Even turning on overflow-hidden doesn't make it go away. The page has nothing but a header, a link, and a panel. How can it be removed?
The HTML is roughly as follows:
<body>
<!-- Document framework -->
<div data-role="page">
<div data-role="panel" id="toolmenu" data-theme="a">
<form>
<fieldset data-role="controlgroup">
<legend>Select Tool:</legend>
<input name="radio-choice-v-2" id="radio-choice-v-2a" value="on" checked="checked" type="radio">
<label for="radio-choice-v-2a">One</label>
<input name="radio-choice-v-2" id="radio-choice-v-2b" value="off" type="radio">
<label for="radio-choice-v-2b">Two</label>
<input name="radio-choice-v-2" id="radio-choice-v-2c" value="other" type="radio">
<label for="radio-choice-v-2c">Three</label>
</fieldset>
</form>
</div>
<div data-role="header">
<h1>TITLE</h1>
</div>
<div data-role="content">
Stuff<br />
Open panel link
</div>
<div data-role="footer" data-position="fixed">
Footer
</div>
</div>
</body>
Thanks.
I solved the problem. The issue was that I had the css files in the wrong order. When you are using a custom theme with jquery mobile, you have to have the css files in a particular order--namely, your themeroller-created custom theme has to come BEFORE the jquery mobile css, and you have to use jquery.mobile.structure-1.4.2.min.css (or the equivalent for whatever version you are using anyway), not the full css file.

#&ui-state=dialog appear automatically when call popup and make error when refresh

I strat 192.168.1.102:8080 to call my server but the url change it into...
http://192.168.1.102:8080/#&ui-state=dialog
Instead of
http://192.168.1.102:8080
which make an error if I refresh the browser. I don't know why it happen like that???
here is my code I call popup to start first to get username
window.onload = function(){
$('#popupLogin').popup("open","slidedown");
}
Here is My popup that I call
<!--POPUP IN THE START UP || NOTE** data-dismissible='false' = Prevent popup close when click outside -->
<div data-role="popup" data-dismissible='false' id="popupLogin" data-theme="a" data-overlay-theme="a"
class="ui-corner-all ui-popup ui-body-a ui-overlay-shadow" aria-disabled="false" data-disabled="false"
data-shadow="true" data-corners="true" data-transition="slidedown" data-position-to="origin">
<form id="startDialog" onsubmit="startActivity()">
<div style="padding:10px 20px;">
<h3>Express Your Feeling</h3>
<!--ID = username, geoFeeling-->
<input required type="text" id="username" value="" placeholder="username"
data-theme="a" class="ui-input-text ui-body-a ui-corner-all ui-shadow-inset">
<textarea required id="geoFeeling" value="" placeholder="Feeling..." style="height: 70px"
data-theme="a" class="ui-input-text ui-body-a ui-corner-all ui-shadow-inset"></textarea>
<button type="submit" data-theme="b" >Log in</button>
</div>
</form>
</div>
<!--------------------------------------------------END OF POPUP --------------------------------------->
and after user completed the form and submit form will call another function to start activity.
Popup box will disappear.
I don't know which part that i was wrong because at the beginning
I can refresh browser and popup will re-open again (re-start activity)
but now URL has change (because of what??) after develop I can't refresh it anymore
Do you have any suggestion or somethings ???
Please Advise.

JQueryMobile not styling a Checkbox in Dialog

I am opening a page as a dialog. This dialog does not style the checkbox correctly.
Tried using checkboxradio("create"); but no joy.
How do I get the checkbox to style correctly in the Dialog box??
Here's a jsFiddle with the code.
You need to put the checkbox in a div with the proper markup
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>Agree to the terms:</legend>
<input type="checkbox" name="checkbox-1" id="checkbox-1" class="custom" />
<label for="checkbox-1">I agree</label>
</fieldset>
</div>
Example: http://jsfiddle.net/shanabus/8xMX2/12/
Based on the example in the docs here: http://jquerymobile.com/demos/1.0a4.1/docs/forms/forms-checkboxes.html
I think you'll have to put the checkbox inside of a form tag in order to get jQuery Mobile to style it.
Looks like this might be a bug. Adding the <form> tag works but you also had create but needed refresh for the checkboxradio():
http://jsfiddle.net/8xMX2/11/
JS
$('#page2').live('pageshow', function(){
$("input[type='checkbox']").checkboxradio("refresh");
});​
HTML
<div data-role="page">
<div data-role="header">
<h1>Page One</h1>
</div>
<div data-role="content">
Open as Dialog
</div>
</div>
<div id="page2" data-role="page">
<div data-role="header">
Back
<h1>Page Two</h1>
</div>
<div data-role="content">
<form>
This is a dialog Box.
JQM seems to be not styling the below checkbox.<br>
<input type="checkbox" name="cb1" id="cb1" />
<label for="cb1">A Checkbox</label>
<br>
A button is styled well.<br>
Just a Button
</form>
</div>
</div>​

Jquerymobile dialog using mobile.changepage doesn't work on second page

I have a dialog (not external html), which is displayed when I click on a button on the page, it works fine if the html containing the dialog is the first page to be accessed , but if that file is opened by clicking on an href from another page, the dialog doesn't show up when I click the button.
Here is the code for the page containing the dialog ... The alert in the click event of the button is showing up even when this is the not the first page to be accessed, but the dialog doesn't show up.
<!DOCTYPE html>
<html>
<head>
<title>Create Team</title>
<link rel="stylesheet"
href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
</head>
<body>
<!-- Page starts here -->
<div data-role="page" data-theme="b" id="page1">
<div data-role="header" id="hdrMain" name="hdrMain"
data-nobackbtn="true">
<h1>Test screen</h1>
</div>
<div data-role="content" id="contentMain" name="contentMain">
<div id="fullnamediv" data-role="fieldcontain">
<label for="fullname" id="fullnameLabel" name="fullnameLabel">Team
Name*</label> <input id="fullname" name="fullname_r" type="text" />
</div>
<div id="submitDiv" data-role="fieldcontain">
<a id="buttonSave" name="buttonSave" href="#" data-role="button"
data-inline="true">Save</a>
</div>
</div>
<!-- contentMain -->
<div data-role="footer" id="ftrMain" name="ftrMain"></div>
<script>
$("#page1").bind("pagecreate", function() {
$('#buttonSave').click(function() {
alert("aaaa");
$.mobile.changePage('#successdiv', {
transition: 'pop',
reverse: false,
changeHash: true
});
alert("after change");
return true;
});
});
</script>
</div>
<!-- page1 -->
<div data-role="dialog" data-theme="a" id="successdiv">
<div data-role="header" data-theme="f">
<h1>Error</h1>
</div>
<div data-role="content">
<p>This is Page 2</p>
<button type="submit" data-theme="e" name="successok"
value="submit-value" id="successbutton">Close Dialog</button>
</div>
</div>
<!-- Page ends here -->
</body>
</html>
You use jQuery Mobile v1.0 but at the same time you pass incorrect arguments to $.mobile.changePage like if it were say v1.0 alpha. Not sure if it solves your problem but worth trying:
$.mobile.changePage('#successdiv', {
transition: 'pop',
reverse: false,
changeHash: true
});
When I jump from one jquery mobile page to another via a hrefs, I have to set the rel attribute to external, like this:
page2
dfsq is right, only the div[data-role="page"] is loaded when you link to this page from another page. I'd suggest moving the dialog into its own html file and opening it either via
open dialog
or
$.mobile.changePage('your_dialog.htm', {role: 'dialog', transition: 'pop'});

Jquery Mobile Dialog with Page element

I'm trying to make the header button of an app launch an embedded form on a page. Any ideas if this is possible or if not what the manual JS would look like to achieve it?
<div data-role="header" class="ui-header ui-bar-a" role="banner">
<h1 class="ui-title" tabindex="0" role="heading" aria-level="1">Devices</h1>
<a class="ui-btn-right ui-btn ui-btn-icon-left ui-btn-corner-all ui-shadow ui-btn-down-a ui-btn-up-a" data-icon="gear" data-rel="dialog" data-transition="flip" href="#filter_form" data-theme="a"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Options</span><span class="ui-icon ui-icon-gear ui-icon-shadow"></span></span></a>
</div>
<!-- other page stuff -->
<div id='filter_form' style='display: none'>
<h3>Device Criteria</h3>
<form accept-charset="UTF-8" action="/devices" method="get">
<div data-role='fieldcontain'>
...
</div>
<div>
<button data-theme='a'>Submit</button>
</div>
</form>
</div>
<script>
//<![CDATA[
$(function(){
$('.show_filter_form').click(function(){
console.log("in click handler")
$.mobile.changePage($('#filter_form form'), {transition: 'pop', changeHash: false, role: 'dialog'});
return false;
})
})
//]]>
</script>
The click is getting triggered but nothing happens on the page except an unstyled back button showing up in the header.
I've setup a js fiddle for it if you have any ideas: http://jsfiddle.net/BHMmP/
Regarding your JS coding, dialog will be pop-up once click on ".show_filter_form". But, Where is this element ".show_filter_form"?

Resources