0

当用户单击按钮delete时,我希望出现一个对话框,以确认删除。我可以让对话框出现在页面加载时,但遇到问题让它出现在按钮点击上:

<?php echo $this->dialogContainer(
'dialog',
'Are you sure you want to delete this postcode?',
array(
    'autoOpen'      => false,
    'draggable'     => true,
    'modal'         => true,
    'resizable'     => true,
    'title'         => 'Confirm Delete',
    'closeOnEscape' => true,
    'buttons'   => array(
        'Delete' =>  new Zend_Json_Expr('function() {
            document.location=\''.$this->url(array(
                'module'     => 'crm',
                'controller' => 'postcode',
                'action'     => 'delete' 
            ),"", true) .'\' 
        }'),
        'Cancel' => new Zend_Json_Expr('function() {
            $(this).dialog(\'close\');
        }')
    ),
),

); ?>

dialogContainer 中是否有允许这样做的东西,或者我是否需要创建一个单独的函数,我单独加载?

谢谢。

4

2 回答 2

1

我过去所做的(使用直接的 jQuery UI,没有 zend)是设置一个 onclick 事件,该事件调用一个函数来打开对话框:

<a onclick='showDialog();'>clickable item</a>

初始化文档中的对话框准备就绪:

var $demoDialog;
$(document).ready(function() {
  $demoDialog= $("#demoDialog").dialog({
    autoOpen: false,
    draggable: true,
    resizable: true
    title: 'Demo Dialog'
  });
});

并添加打开它的功能:

function showDialog() {
  if (!$demoDialog.dialog('isOpen')) {
    $demoDialog.dialog('open');
  }
}
于 2010-09-10T20:51:37.763 回答
1

试试看

       $this->jQuery()->addOnLoad("
          $('a').click(function(){                    
             $('#dialog').dialog('open');
          });
       ");
于 2010-10-08T19:54:21.387 回答