==
function onCheck()
{
// It's simple page, not component, partial or controller
// Therefore this syntax is right (according October docs)
$this['myvar'] = "Hello";
}
==
<form class="dates" action="" method="POST" data-request="onCheck">
<input type='text' class='date_inout' name="start" id='start'>
<input type='text' class='date_inout' name="end" id='end'>
<input type="submit" value="Подобрать">
</form>
<h1>{{ myvar }}</h1>
myvar
未输出。我只需要在表单提交后获取myvar
,而不需要onStart
或onInit
提前谢谢!
答案 0 :(得分:0)
仅在ajax之后需要输出,然后您需要这样做
==
function onCheck()
{
$dates = post('start') . ' - ' . post('end');
return ['#myvarContsiner' => "Hello " . $dates];
// ^ this id
}
==
<form class="dates" action="" method="POST" data-request="onCheck">
<input type='text' class='date_inout' name="start" id='start'>
<input type='text' class='date_inout' name="end" id='end'>
<input type="submit" value="Подобрать">
</form>
<h1 id="myvarContsiner"></h1>
<!-- this id ^ -->
现在,当您按下
submit button
时,它将转到onCheck
并返回值['#myvarContsiner' => "Hello " . $dates]
,因此基本上"Hello " . $dates
将根据在<h1 id="myvarContsiner"></h1>
中更新匹配的ID 。
和您的 将显示从onCheck
如有疑问,请发表评论。