Reputation: 866
i am fetching a page using get ajax call.
$.get('/notification/viewmessage',{user:username},function(data){
//my code here
});
i wan't to disable the layout of the page on some $.get
calls only.
the default layout disable function in zend is $this->_helper->layout->disableLayout();
but i don't want to do this in all page requests.
can i do this by adding some code in the js request itself?
thanks in advance.
Upvotes: 0
Views: 234
Reputation: 2006
You'd probably want to add a flag to your viewmessage script.
$.get('/notification/viewmessage?layout=false',{user:username},function(data){
//my code here
});
Then in the viewmessage script you'd have something like this at the top of the script.
if($this->getRequest()->getParam('layout') == 'false')
{
$this->_helper->layout->disableLayout();
}
Upvotes: 1
Reputation: 164895
This is what the AjaxContext action helper does out of the box.
Simply add the config calls to your controller's init()
method, create a .ajax.phtml
view and render it in your normal view script. For example
public function init()
{
$this->_helper->ajaxContext->addActionContext('viewmessage', 'html')
->initContext('html');
// this avoids having to pass a format param
}
In notification/viewmessage.phtml
<?php echo $this->render('notification/viewmessage.ajax.phtml') ?>
and place your normal view contents in notification/viewmessage.ajax.phtml
Upvotes: 1