nette.ajax.history, filtering and redirect

Notice: This thread is very old.
mcmatak
Member | 490
+
0
-

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

and

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

		if (!$this->isAjax()) {
			$this->redirect('this');
		}
		else {
			$this->redrawControl('accountsList');
		}
	}

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

i dont want to have do=filter in my url

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

	public function renderDefault()
	{
		if ($this->isAjax()) {
			$this->redrawControl('accountsList');
		}
	}

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?

jan.vince
Member | 8
+
0
-

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]);
		$this->redrawControl('notesBox');

} else {

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

}

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