Skip to content

blueweb/history.nette.ajax.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

History Extension

Adds History API support to nette.ajax.js addon for Nette Framework!

This repo is a fork of vojtech-dobes/history.nette.ajax.js package with additional support for Nette 3.

All credits go to Vojtěch. Thank you!

Installation

  1. Link client-side/history.ajax.js after nette.ajax.js.
  2. Load PHP files with Composer: blueweb/nette-ajax-history
  3. Register config extension in your configuration:
extensions:
	ajaxHistory: Blueweb\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">...</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;

About

Adds History API support to nette.ajax.js addon!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 54.9%
  • JavaScript 45.1%