0

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.

1
  • 1
    you could add a variable to the URL then check that in the page. Commented Feb 29, 2012 at 5:13

2 Answers 2

1

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();
}
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.