I'm testing ATK4 for some scenarios to decide, if I can go with it. One of these Scenarios is a status page for groups and members, which should reload automatically the grids, which contains dynamic group and member informations.
The grid reload I've implemented like described in this Thread Agile toolkit : how to automatically reload grid
Here's the code for the members page:
<?php
class page_members extends Page {
function init(){
parent::init();
$page = $this;
$page->api->stickyGET('group_id');
$grid = $page->add('Grid');
$model = $grid->setModel('Member');
if ($_GET['group_id'])
$model->addCondition('group_id', $_GET['group_id']);
$page->js(true)->univ()->setInterval(
$grid->js()->reload()->_enclose()
,10000);
}
}
If I call it from the Browser with the group_id parameter, it works like expected. But this page will called from a group page into a frameURL with the following code:
<?php
class page_groups extends Page {
function init(){
parent::init();
$page = $this;
$grid = $page->add('Grid');
$model = $grid->setModel('Group');
$grid->addColumn('button','members');
if($_GET['members']){
$grid->js()->univ()
->frameURL('Members' ,$page->api->url('../members',array('group_id'=>$_GET['members'])))
->execute();
}
$page->js(true)->univ()->setInterval(
$grid->js()->reload()->_enclose()
,10000);
}
}
If I click on button 'members' from group 1, the members page for group 1 open in a frame and refreshes every 10 seconds. That's okay. But if I close the frame and open a new frame by clicking on 'members' button from group 2, the grid cycling through group 1 and 2 while refreshing the grid.
I think, the problem is the timer, created by the setInterval()
function, which has to be cleared by clearInterval(id)
before the frame is closed. The setInterval()
function has a return value, but I don't know, how I can handle it over to the clearInterval(id)
function in the ATK4 Framework?