Invalidace komponenty funguje jen pres handle metodu
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Coura
- Člen | 20
Zdravim,
mam komponentu kosiku, kde pridani nove polozky probiha budto pres handle metodu
nebo odeslanim formulare, oboje pres AJAX. Invalidace, ale v metode obsluhujici
formular nefunguje. Mam verzi 1.0-dev z 8.6.2010
<?php
public function handleAdd($id, $count = 1, $variant = 0)
{
$this->addItem($id, $count, $variant);
$this->flashMessage(_("Goods were successfully inserted into the basket."));
$this->invalidateControl('basketSmall');
$this->invalidateControl('basketMessages');
if (!$this->presenter->isAjax())
$this->presenter->redirect('this');
}
public function addToBasketSubmitted(AppForm $form)
{
$data = $form->getValues();
foreach($data["count"] as $id => $count) {
if($count && $data["variant"][$id]) {
$this->addItem($data['productId'], $count, $id);
}
}
$this->flashMessage(_("Goods were successfully inserted into the basket."));
$this->invalidateControl('basketSmall');
$this->invalidateControl('basketMessages');
if (!$this->presenter->isAjax())
$this->presenter->redirect('this');
}
?>
Je to skoro stejne, zavinacema to byt nemuze, kdyz pro handle to funguje. Pokud dam invalidaci do presenteru, tak se taky zadnej snippet neinvaliduje.
Diky za radu
EDIT: opraveno, bylo to kvuli velkymu pismenu pri volani te komponenty v sablone
Editoval Coura (10. 9. 2011 12:10)