Kohana 3中的控制器似乎不起作用,但在后台运行 [英] Controller in Kohana 3 does not appear to work, but has in the background

查看:97
本文介绍了Kohana 3中的控制器似乎不起作用,但在后台运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户发现,当他们点击删除时,什么也没发生,但是如果再次出现,他们会得到一个错误,即不再存在'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.

视图中的链接:

<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");
}

有人知道这怎么可能吗?

Does anyone know how this can be possible?

推荐答案

这可能是由于Kohana和您选择的浏览器之间的双重扼流圈缓存.

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.

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

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

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

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

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;

您可以从 system/classes/kohana/core.php

这篇关于Kohana 3中的控制器似乎不起作用,但在后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆