Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vojtech-dobes/history.nette.ajax.js
Adds History API support to nette.ajax.js addon!
https://github.com/vojtech-dobes/history.nette.ajax.js
Last synced: 5 days ago
JSON representation
Adds History API support to nette.ajax.js addon!
- Host: GitHub
- URL: https://github.com/vojtech-dobes/history.nette.ajax.js
- Owner: vojtech-dobes
- Created: 2014-03-03T17:00:58.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-01-18T09:23:37.000Z (over 2 years ago)
- Last Synced: 2024-09-25T20:44:27.190Z (8 days ago)
- Language: PHP
- Size: 30.3 KB
- Stars: 30
- Watchers: 6
- Forks: 27
- Open Issues: 15
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# History Extension
Adds History API support to nette.ajax.js addon for Nette Framework!
## Installation
1. Link `client-side/history.ajax.js` after `nette.ajax.js`.
2. Load PHP files with Composer: `vojtech-dobes/nette-ajax-history`
3. Register config extension in your configuration:```
extensions:
ajaxHistory: VojtechDobes\NetteAjax\HistoryExtension
```## Usage
Write your application as normal. All redirects and forwards will be properly handled.
To correctly update UI, use snippets. If you plan to ajaxify whole application, consider adding this snippet to your `beforeRender()` method in `BasePresenter`.
```php
if ($this->isAjax()) {
$this->invalidateControl('title');
$this->invalidateControl('content');
}
```And `app/@layout.latte` might be upgraded accordingly:
```html
...
``````html
{snippet content}
{include content}
{/snippet}
```### Disabling
If you want specific links or forms exclude from scope of this addon (not make them update the URL), you can use `data-ajax-off` feature of *nette.ajax.js*.
```html
```## UI Caching
Extension will automatically cache your UI and restore it on *Back* and *Forward* buttons without communication with server. If you wish to call server on every *Back* and *Forward*, turn caching off.
```js
$.nette.ext('history').cache = false;
```