Problém s Ajax – pri volani handlera a invalidateControle sa neprekresli len snippet ale cela sablona
- misiak
- Člen | 28
Ahoj,
narazil som na jeden problem v projekte, kvoli ktoremu som si spravil mensi testovaci projekt. Problemom je, ze ak zavolam test! tak sa vobec neprekresli snippet ale v odpovedi sa vrati cela stranka akoby som ju ani nevolal ajaxom a samozrejme obsah snippetu je prazdny akoby som signal vobec nezavolal len default action.
@layout.phtml
<?php
{**
*
* @param string $basePath web base path
* @param string $robots tell robots how to index the content of a page (optinal)
* @param array $flashes flash messages
*}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="Nette Framework web application skeleton" />
<meta name="robots" content="{$robots}" n:ifset="$robots" />
<title>Nette Application Skeleton</title>
<link rel="stylesheet" media="screen,projection,tv" href="{$basePath}/css/screen.css" type="text/css" />
<link rel="stylesheet" media="print" href="{$basePath}/css/print.css" type="text/css" />
<link rel="shortcut icon" href="{$basePath}/favicon.ico" type="image/x-icon" />
<script type="text/javascript" src="{$basePath}/js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="{$basePath}/js/jquery.nette.js"></script>
<script type="text/javascript" src="{$basePath}/js/ublog.js"></script>
</head>
<body>
<!-- wrapper //-->
<div id="wrapper">
{snippet zobrazenie}
{ifset $sprava}Test: {$sprava}{/ifset}
{/snippet}
<a href="{plink test!}" class="ajax">Testuj snippet</a>
</div>
</body>
</html>
?>
DefaultPresenter.php
<?php
use Nette\Debug;
class DefaultPresenter extends BasePresenter
{
public function handleTest()
{
$this->template->sprava = 'test';
$this->invalidateControl('zobrazenie');
}
}
?>
Pri zavolani bez javascriptu to funguje, ale akonahle zavolam odkaz cez ajax, nevrati sa mi odpoved v json formate ale normalne ako html cely vyrenderovany layout bez toho aby tam bola zmienka o nastavenej premennej $sprava.
Neviete co s tym? alebo mi nieco uniklo? uz 2 dni sa to snazim vyriesit, narazil som na to pri projekte ked som robil vlastnu komponentu.
Nette mam 3fe360… z githubu
Editoval misiak (25. 8. 2010 12:27)