nette.ajax.history, filtering and redirect

Notice: This thread is very old.
Member | 485

some examples,

1. filtering

  • above the list of items you need to filter according to name, id, or any other attribute
  • there is links, ie.: show only ACCOUNT ID = 5

after filtering i need to change url, so i can use nette.ajax.history and i have two options

<a class=“ajax margin btn btn-primary” href=“{plink filter!, account_id ⇒ $account->id}”>{$account->name}</a>


	public function handleFilter($account_id)
		$this->account_id = $account_id;

		if (!$this->isAjax()) {
		else {

but this means my url will be changed like /?account_id=5&do=filter

i dont want to have do=filter in my url

<a class=“ajax margin btn btn-primary” href=“{plink this, account_id ⇒ $account->id}”>{$account->name}</a>

	public function renderDefault()
		if ($this->isAjax()) {

but this option means i send snippet accountsList every time a make ajax, for example i open the modal dialog, i filter in another form etc.? i dont want this

so how to solve this?



I use something like this inside of handle to update URL in browser:

if ($this->isAjax()) {

		$this->payload->url = $this->link('this',['page' => $this->page]);

} else {

		$this->redirect('this', ['page' => $this->page]);


Not sure this is the best solution but this works for me :)

5 years ago