vojtech-dobes / nette-ajax-history
Adds History API support for Nette Framework.
Installs: 169 490
Dependents: 7
Suggesters: 0
Security: 0
Stars: 30
Watchers: 6
Forks: 27
Open Issues: 15
Requires
- php: >=5.3.1
- nette/nette: ~2.0
This package is not auto-updated.
Last update: 2024-12-21 15:49:50 UTC
README
Adds History API support to nette.ajax.js addon for Nette Framework!
Installation
- Link
client-side/history.ajax.js
afternette.ajax.js
. - Load PHP files with Composer:
vojtech-dobes/nette-ajax-history
- 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
.
if ($this->isAjax()) { $this->invalidateControl('title'); $this->invalidateControl('content'); }
And app/@layout.latte
might be upgraded accordingly:
<title n:inner-snippet="title">...
{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.
<a class="ajax" data-ajax-off="history">
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.
$.nette.ext('history').cache = false;