$html->cakephp 中的链接中的警报框

发布于 2024-07-29 04:51:53 字数 386 浏览 9 评论 0原文

我知道点击链接时获取确认消息的代码如下所示。

<?php 
     echo $html->link('Delete',
            array('controller'=>'forms','action'=>'delete', $r['Form']['id']),
            array(),
            'really delete the Form ?',
            false
            );
        ?>

通过单击确认消息中的“确定”按钮删除表单后,我需要一个警告框,显示“您的表单已被删除”。

有没有办法获得警告框而不是确认框或确认框后出现警告框?

I know that the code to get a confirm message while clicking on a link is as given below.

<?php 
     echo $html->link('Delete',
            array('controller'=>'forms','action'=>'delete', $r['Form']['id']),
            array(),
            'really delete the Form ?',
            false
            );
        ?>

I need an alert box saying "Your form has been deleted" after deleting the form by clicking on the 'ok' button in the confirm message.

Is there a method to get an alert box instead of the confirm box or an alert box after the confirm box?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

还在原地等你 2024-08-05 04:51:53

我找到了使用 Ajax 助手的答案。 蛋糕书上都有,我只要仔细看一下就可以了。 不使用$html->link,需要使用$ajax->link
以下是获取 html 链接中警报框的代码。

<?php
      echo $ajax->link('Publish',
     array('controller'=>'forms','action'=>'publish', $formid),
      array('update'=>'view','complete'=>'alert("Your form has been published")')
      'Are you sure?',false);
?>

警报框在操作完成后调用,并应在 $ajax->link 数组的“完成”条件中提及。

I found out the answer which uses the Ajax helper. It is all in the cake book, I just need to read it more carefully. Instead of using $html->link,need to use $ajax->link
Here is the code to get the alert box in the html link.

<?php
      echo $ajax->link('Publish',
     array('controller'=>'forms','action'=>'publish', $formid),
      array('update'=>'view','complete'=>'alert("Your form has been published")')
      'Are you sure?',false);
?>

The alert box is called after the action is completed and should be mentioned in the 'complete' condition of the $ajax->link array.

以往的大感动 2024-08-05 04:51:53

您需要使用 JavaScript 来执行此操作。 将触发单击事件,在该事件中,您将调用“alert("hey!");” 这确实独立于 CakePHP 框架,因为我认为没有 JavaScript 帮助器可以做到这一点。

You'll need to use JavaScript to do this. A click event would fire and in that event, you would call "alert("hey!");" This is really independent of the CakePHP framework, as I don't think there's a JavaScript helper to do that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文