problem hned na zacatku nette.ajax.js
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- vosy
- Člen | 532
nedari se mi rozbehnout nette.ajax na formular :(
formular:
<?php
namespace App\Factories;
use Nette\Forms\Form;
class FormFactory
{
public function __construct()
{
}
public function mainForm()
{
$form = new Form;
$form->addSubmit('reloadSnippet', 'Reload');
$form->onSuccess[] = callback($this, 'mainFormSubmitted');
return $form;
}
public function mainFormValidate($form)
{
}
public function mainFormSubmitted(Form $form)
{
}
}
sablona:
{* This is the welcome page, you can delete it *}
{block content}
<div id="content">
{snippet presenterContainerSnippet}
<div id="presenterCont">
{time()}
</div>
{/snippet}
{form reloadSnippetPresenterForm}
{input reloadSnippet class=>"ajax"}
{/form}
<footer>Nette Framework {Nette\Framework::VERSION}</footer>
</div>
{/block}
presenter:
<?php
namespace App\Presenters;
use Nette,
App\Model;
/**
* Homepage presenter.
*/
class HomepagePresenter extends BasePresenter
{
public $FormFactory;
public function injectFormFactory(\App\Factories\FormFactory $FormFactory)
{
$this->FormFactory = $FormFactory;
}
public function renderDefault()
{
}
protected function createComponentReloadSnippetPresenterForm()
{
$form = $this->FormFactory->mainForm();
return $form;
}
}
hlavni layout:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{ifset #title}{include title|striptags} | {/ifset}Nette Sandbox</title>
<link rel="stylesheet" media="screen,projection,tv" href="{$basePath}/css/screen.css">
<link rel="stylesheet" media="print" href="{$basePath}/css/print.css">
<link rel="shortcut icon" href="{$basePath}/favicon.ico">
<script type="text/javascript" src="{$basePath}/plugins/jquery/1.10.2/min.js"></script>
<script type="text/javascript" src="{$basePath}/plugins/jquery-ui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="{$basePath}/plugins/netteAjax/nette.ajax.js"></script>
<script src="{$basePath}/js/main.js"></script>
</head>
<body>
{include content}
</body>
</html>
main.js:
$(function(){
$.nette.init();
$.nette.ext('', {
success: function (payload, status, jqXHR, settings)
{
if(settings.nette.isSubmit)
{
var id = settings.nette.ui.id;
var idForm = settings.nette.form[0].id;
alert('Stlacene tlacitko');
}
}
});
$.nette.load();
});
a pri stisknuti tlacitka „reloadSnippet“ se stranka reloadne, misto aby zafungoval js :(
je tam urcite nejaka banalita, jen mi to uz nemysli :(
dekuji