Hi,

I'm using multiple contextSwitch contexts, and they all work great. 
However, now I need to add an AjaxContext, and I can't seem to get it to
work.  If I comment out my regular contextSwitch, the AjaxContext works
fine.  It's only a problem when I use them both at the same time.  What am I
doing wrong?  Here is what is broken:

public function init()
{        
        // set ajax context
        $ajaxContext = $this->_helper->getHelper('AjaxContext');
        $ajaxContext->addActionContext('detail', array('html'));
        $ajaxContext->initContext();
        
        // enable custom contexts
        $contextSwitch = $this->_helper->getHelper('contextSwitch');
        
        // add action contexts
        $contextSwitch->addActionContext('list',                array('json', 
'xml',
'webwidget'));
        $contextSwitch->addActionContext('discover',    array('json', 'xml',
'webwidget'));
        $contextSwitch->addActionContext('detail',              array('json',
'webwidget'));
        $contextSwitch->addActionContext('follow',              array('json'));
        $contextSwitch->addActionContext('unfollow',    array('json'));
        $contextSwitch->addActionContext('following',   array('json'));
        
        $contextSwitch->setAutoJsonSerialization(false); 
        
        // init the context
        $contextSwitch->initContext();
}

I know that AjaxContext extends contextSwitch, so I thought I could combine
them like below, but that doesn't work either:

public function init()
{        
        // enable custom contexts
        $contextSwitch = $this->_helper->getHelper('AjaxContext');
        
        // add action contexts
        $contextSwitch->addActionContext('list',                array('json', 
'xml',
'webwidget'));
        $contextSwitch->addActionContext('discover',    array('json', 'xml',
'webwidget'));
        $contextSwitch->addActionContext('detail',              array('json',
'webwidget', 'html'));
        $contextSwitch->addActionContext('follow',              array('json'));
        $contextSwitch->addActionContext('unfollow',    array('json'));
        $contextSwitch->addActionContext('following',   array('json'));
        
        $contextSwitch->setAutoJsonSerialization(false); 
        
        // init the context
        $contextSwitch->initContext();
}

How can I add an AjaxContext to the 'detail' action without it breaking the
existing contexts?
-- 
View this message in context: 
http://www.nabble.com/Using-both-AjaxContext-and-contextSwitch-together.-tp24105715p24105715.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to