0

When a user clicks on the button delete, I want a dialog box to appear, to confirm the delete. I can get the dialog box to appear on page load, but am running into problems getting it to appear on a button click instead:

<?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\');
        }')
    ),
),

); ?>

Is there something in the dialogContainer that allows this, or do I need to create a separate function, which I load separately?

Thanks.

4

2 に答える 2

1

私が過去に行ったこと (zend を使用せずに jQuery UI をそのまま使用) は、関数を呼び出してダイアログを開く 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 に答える