2011年1月19日星期三

[fw-mvc] AjaxContext action helper not disabling layouts?

I'm using ZF-1.11.2. In the init() method of my controller is this code:

// configure the ajax context switch helper
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext
->addActionContext('sortmanufacturer', 'html')
->addActionContext('sorttype', 'html')
->addActionContext('emailoffer', 'html')
->addActionContext('emailfriend', 'html')
->initContext();

But i noticed that the entire view w/ layout is being returned. I'm having
to explicitly include:

$this->_helper->layout->disableLayout();

in each action in which a switch occurs. I should mention that the actions
in which this behavior occurs are not accessed via a typical http
request...they are being called by XHR only without having a typical http
view. For example, the action manufacturerAction() will, in it's viewscript,
make a call to sortmanufacturerAction via XHR. But sortmanufacturerAction is
returning the layout in it's response. sortmanufacturerAction() is never
accessed as a stand-alone action. I don't know if this matters, but this
wasn't the behavior prior to 1.11 as far as I know (hadn't tested it in a
while prior to upgrading to 1.11.2, and can't remember what version I
upgraded from, sorry!). All I had to do was setup the context switch as
above and nothing else was needed.

Am I using the ajaxContext incorrectly, or am I misunderstanding how it
works, or both?

--regards,
nathan

没有评论: