I am working on zend framework, PHP and jQuery. I am working on popups sometimes. When any popup is open on the screen, we can still clicks links on webpage behind popup which causes some unexpected behaviour. How can I disable a webpage behind popup. I have seen some web application in which when popup appears then webpage behind popup become shady.
I have read some tutorial about this. In each tutorial a link is used to open a dialog and an special attribute is added in anchor tag for modal. But I have a different case I have to open dialog on some condition in action.
I check a condition in action after post like this:
$form = new Edit_Form( );
$this->view->form = $form;
$this->view->form->setAction($this->view->url());
$request = $this->getRequest();
if ( $request->isPost() ) {
$values = $request->getParams();
if( $values['edit'] ) {
$this->view->openEditBox();
}
}
Now check in view to see that it should open an edit pop or not:
if( $this->openEditBox ){
$jsonOutput ['content'] = '<div class="DialogBox" title="Edit">' . $this->form->render() . '</div>';
echo Zend_Json::encode($jsonOutput);
}
‘content’ is a DIV on my webpage.
Any Idea? Thanks
This is done via Javacript and is called a Modal Window.
You can achieve this easily with the Dialog component in JQueryUI. Other implementations are widely available.
You can use
ZendX_JQuery_View_Helper_DialogContainerto create a modal dialog with ZF. You have to enable the library first though, as it is not part of the standard distribution. Then you can use the following in your View:* Note: haven’t worked with these helpers, so the above snippet might need adjustment
Usage of
dialogContaineris pretty straightforward:See the ZF manual for further information on how to setup and use ZendX_JQuery