cameronaskew / jquery.mobile.paramshandler Goto Github PK
View Code? Open in Web Editor NEWA plug-in for adding URL parameters to jQuery Mobile pages
License: MIT License
A plug-in for adding URL parameters to jQuery Mobile pages
License: MIT License
I want to be able to use a URL with parameters in it so I can export the current state of the page and later come back to that same state. Without getting into too much detail, just assume there are generic filters on the page. I want to be able to load the page with something like www.site.com/?filter=true&color=blue. The problem seems to be that upon entry into the site, the #loginPage is loaded and if already logged in (localStorage saves a Token to test login status), it uses $.mobile.changePage("#mainPage"). When it does that, the URL now looks like this: www.site.com/?filter=true&color=blue#mainPage. I think since the #mainPage is after the query, it's causing issues with your plugin because I'm not getting anything back using it to grab the params!
I am not able to use more than one page (ID). I am doing so the information but still no work.
#1. When I add one second ID with comma at the end, the code does not work, but if I remove the comma code back to work.
#2. When I add a third ID for the page, all the code does not work.
Any solution?
Thanks You.
$(function () {
$.mobile.paramsHandler.addPage(
"page_1", "page_2", "page_3" ,
["id", "name"],
[],
function (urlParams) {
MyFunctionLoadList(urlParams.id);
}
);
$.mobile.paramsHandler.init();
});
If I go from
to #two?id=finger
to #two?id=ship
And then press the back button, I am sent back to #one and not #two?id=finger.
@CameronAskew thanks for this I was banging my head with jqm.page.params
couldn't get it to work with JQM 1.4 glad I found this, unfortunately I am unable to get this to work also. Hopefully you can help. I have included the <script src="../js/jquery.mobile.paramsHandler-1.4.2.js"></script>
in my header after jquery mobile library. On the page that I need the parameter I included the script on the head. But I can't seem to get it to work
Here's my page header, included in pages with php
header
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0 ">
<title><?php echo $page_title; ?></title>
<link rel="stylesheet" href="../themes/iCare.css"/>
<link rel="stylesheet" href="../themes/Carelincs.css" />
<link rel="stylesheet" href="../themes/Carelincs.min.css" />
<link rel="stylesheet" href="../themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile.structure-1.4.3.min.css" />
<link rel="stylesheet" href="../raty/jquery.raty.css"/>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.js"></script>
<script src="../raty/jquery.raty.js"></script>
<script src="../js/jquery.mobile.paramsHandler-1.4.2.js"></script>
</head>
And here's my page that I am requesting the key
?php
$page_title = "IntelyCare: Activate";
//$page_description = "Description of this page";
require_once ("../template/header.php");
?>
<body>
<script>
$(function () {
$.mobile.paramsHandler.addPage(
"activatepage", // jquery mobile page id which will accept parameters
["key"], // required parameters for that page
[], // optional parameters for that page,
function (urlVars) {
$("#keyparam").html(urlVars.key);
}
);
$.mobile.paramsHandler.init();
});
</script>
<div data-role="page" id="activatepage">
<div data-role="header" data-position="inline">
<h1>IntelyCare</h1>
</div>
<div data-role="main" data-theme="a" class="ui-ui-content">
<div data-role="content" >
<div id="keyparam"></div>
<h2>Enter Actication Code</h2>
<p>An activation code was sent to your email</p>
<form data-ajax="false" action="" method="POST" id="activate">
<label for="activate">Enter Activation Code</label>
<input type="text" name="activate" placeholder="Enter code" value="<?php if(isset($_GET['key'])) { echo $_GET['key']; } ?>"/>
<input name="keyid" id="keyid"/>
<br />
<div id="message"></div>
<button type="submit" id="submit">Submit</button>
</form>
<a href="resendkey.php">Request new activation code</a>
</div>
</div>
</div>
</body>
If I use this plugin, none of my other functions work, if I delete it, all the functions work. For example, I had this function also:
function myFunction() { document.getElementById("demo").innerHTML = "YOU CLICKED ME!"; }
If I remove the plugin usage from my file, this function works but if I add the plugin, the function does not work, same goes for all other functions in the file
No bugs to report, just wanted to say thank you so much for this library! I was ripping every last shred of my hair out trying to get simple parameter passing to work in jQuery Mobile. This project was a life-saver. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.