Monday, August 20, 2012

jQuery Form IFrame

When jQuery.form iframe option is assigned to true,
the result of the iframe will be triggered twice if the result contains javascript.

The solution to the problem is to assign [textarea] tag to wrap up the contain.
But having tags within the textarea tag will cause some unexpected result on the contain.
Therefore, php htmlentities shall fix the issue for the tags within the content.

If you are running on Zend, there will be issue.
By default, you may disable the layout and display the action view template.
But due to requirement to wrap the output with textarea,
we shall need to disable the view template, and do a manual output of the view file.

Solution (in controller):
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);

$sView = $this->getViewScript();

if ($this->getRequest()->isPost()) {
   return "[textarea]" . htmlentities($this->view->render($sView)) . "[/textarea]";
} else {
   return $this->view->render($sView);
}


This solution shall output a normal view if its not submitted from the form.

No comments: