Kohana 3 中的控制器似乎无法工作,但在后台有

发布于 2024-11-25 09:12:34 字数 652 浏览 3 评论 0原文

我的客户发现,当他们点击删除时,什么也没有发生,但如果他们再次点击,他们会收到该“id”不再存在的错误。

我发现这很难相信,因为它实际上离开了页面,然后被重定向回帖子。

视图中的链接:

<h4>Current Logo Image <span class='del'>
 (<?= HTML::anchor("playlist/imgdelete/$playlist->id/$logo->type", 'delete'); ?>)
</span></h4>

控制器进程:

public function action_imgdelete($id, $type)
{
    DB::delete('images')->where('playlist_id', '=', $id)
                        ->where('type', '=', $type)->execute();
    Message::success('Image deleted');
    Request::current()->redirect("playlist/edit/$id");
}

有谁知道这是如何实现的?

My client is finding that when they hit delete nothing happens, but if they it it again they get the error that that 'id' doesn't exist anymore.

I find that hard to believe because it's actually leaving the page and then being redirected back to the post.

The link in the view:

<h4>Current Logo Image <span class='del'>
 (<?= HTML::anchor("playlist/imgdelete/$playlist->id/$logo->type", 'delete'); ?>)
</span></h4>

The controller process:

public function action_imgdelete($id, $type)
{
    DB::delete('images')->where('playlist_id', '=', $id)
                        ->where('type', '=', $type)->execute();
    Message::success('Image deleted');
    Request::current()->redirect("playlist/edit/$id");
}

Does anyone know how this can be possible?

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

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

发布评论

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

评论(1

橘和柠 2024-12-02 09:12:34

这可能是由于 Kohana 和您选择的浏览器之间存在双重阻塞缓存所致。

删除操作将会发生,但由于激进,页面的缓存不会显示任何更改。再次点击将无效,因为您已经执行了该操作,但您的末端没有任何视觉记录。

您可以通过在模板中放入 no-cache 标头标签来解决此问题:

<meta http-equiv="cache-control" content="no-cache" />

Kohana 设置的默认缓存寿命是一分钟:

/**
 * @var  integer  Default lifetime for caching, in seconds, 
 *                 used by [Kohana::cache]. Set by [Kohana::init]
 */
public static $cache_life = 60;

您可以从 system/classes/kohana/core.php 进行调整

This could be due to a double chokehold cache between Kohana and your browser of choice.

The delete action will have occurred, but because of the aggressiveness, the cache of the page will not show any change. Hitting again will be invalid since you've already performed the action, but nothing has visually registered on your end.

You can get around this by putting in the no-cache header tag in your template:

<meta http-equiv="cache-control" content="no-cache" />

The default cache life set by Kohana is a minute:

/**
 * @var  integer  Default lifetime for caching, in seconds, 
 *                 used by [Kohana::cache]. Set by [Kohana::init]
 */
public static $cache_life = 60;

You can tweak it from system/classes/kohana/core.php

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