Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/json2d/jquery.mobile.router
a simple hash router extension for JQM, for handling url hash paths requests
https://github.com/json2d/jquery.mobile.router
Last synced: 27 days ago
JSON representation
a simple hash router extension for JQM, for handling url hash paths requests
- Host: GitHub
- URL: https://github.com/json2d/jquery.mobile.router
- Owner: json2d
- Created: 2015-10-24T03:56:50.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-12T09:50:11.000Z (about 9 years ago)
- Last Synced: 2023-03-01T18:55:49.955Z (almost 2 years ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## JQM Router ##
> compatible with **JQM-1.4.4**
a simple hash router extension for JQM, for handling url hash paths requests like '#user?id=1234'
### Install ###
```html
```### Usage ###
```javascript
$(document).on('mobileinit', function(event){
//define some routes and callback handlers
$.mobile.router.get('user', function(params) {
alert('user id is'+params.id);
})
//have alot of routes? consider chaining!
$.mobile.router
.get('warm:water', function() { alert('is a terrible drink to order.') })
.get('hot:chocolate', function() { alert('is the best.') })//The router also accepts a object hash of callback handlers
var mapping = {
cali : function() { alert('sunny') },
philly : function() { alert('always sunny') }
}
$.mobile.router.get(mapping)//JQM Event data
$.mobile.router.get('eventData', function(params,event,data) {
alert('params: %s, data: %s', params, data)
event.preventDefault()
window.history.back()
})
})
```