Deanna Bonds wrote:
If it doesn't work through the context switcher, I might can set up a
callback on the json context and chain the existing method and set up
a post processor for it. Then in the code have something like
array( 'handler' => array('somewildtagname' => 'javascript code')
Then in the post processor do a regex for that string and remove it
and the quotes around the javascript code. Have to investigate the
possibility of chaining the json context output though.
I went ahead an implemented this. It will be part of my ZendX_ExtJS
package. When I set up my ajaxcontext I add this
$this->ajaxContext->initContext();
$this->ajaxContext->setCallback('json', 'post' , array($this,
'postProcess'));
And my postProcess function looks like this
function postProcess(){
$this->ajaxContext->postJsonContext();
$body = $this->ajaxContext->getResponse()->getBody();
while(mb_ereg('\{"__ZendX_ExtJS_Handler_Data_994434":"--START--(.*?)--END--"\}',
$body, $match) ){
$body = str_replace($match[0],$match[1],$body);
}
$body = $this->ajaxContext->getResponse()->setBody($body);
}
I created a small class to hold the handler
class ZendX_ExtJS_Handler
{
public $__ZendX_ExtJS_Handler_Data_994434 = '';
/**
* Creates a handler for javascript
* @param string javascript string
*/
function __construct($js='')
{
$this->__ZendX_ExtJS_Handler_Data_994434 = "--START--". $js
."--END--";
}
}
and to use it I just set (array(
'handler' => new
ZendX_ExtJS_Handler('function(){ do stuff here ;}'),
'more tags' => ....