Kohana 3.1:从另一个控制器中调用另一个控制器;不返回数据
我似乎无法解决这个问题...我有几个问题,请耐心等待! :)
首先,设置:
我有一个扩展 Controller_Template 的控制器(controllerA)。在controllerA 的模板视图中,我有jQuery 选项卡,它可以AJAX 加载另一个控制器(controllerB)。然后我有一个“核心”控制器,其中包含我在其他控制器中重用的功能(好吧,无论如何我都愿意)。
现在我的问题是:
1. 像我上面提到的那样加载 jQuery 选项卡内容是否可以(最佳实践):
?
2. 在 JS 和 PHP 中,我一直有一个用于可重用代码的“核心”文件。有没有更好的替代方法?我应该让我的核心扩展控制器,然后扩展我的所有控制器吗?但我担心开销。
3. 最后,如果我使用 Request::factory()->execute()->response()
调用核心,除非使用像 die($data)
而不是 return $data
它。但是,如果我从核心中的另一个函数调用该函数,它将无法工作。我怎样才能让它全面发挥作用?
感谢您一如既往的帮助!
布莱恩
I just can't seem to get my head wrapped around this... I have a few questions, please bear with me! :)
First, the setup:
I have a controller (controllerA) which extends Controller_Template. Inside controllerA's template view I have jQuery tabs which AJAX-loads another controller (controllerB). And then I have a "core" controller which contains functions that I reuse within other controllers (well, I would LIKE TO anyway).
Now for my questions:
1. Is it okay (best practice) to be loading the jQuery tab contents like I mentioned above, with:<li><a href="/controller">test</a></li>
?
2. In JS and PHP I've always had a 'core' file for reusable code. Is there a better alternative to doing it this way? Should I instead have my core extend Controller and then extend all my controllers off of that? I'm concerned about the overhead though.
3. Last, if I call the core with Request::factory()->execute()->response()
, I get nothing back unless I use something like die($data)
instead of return $data
it. But if I call that function from within another in the core, it won't work. How can I make it work across the board?
Thanks for your help, as always!
Brian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
项目 URI。或者你将修改所有
更改路由规则后您的看法。
基本控制器类 - 它将是
所有其他的父类
控制器。
Request::factory()->execute()->response()
返回字符串,所以你至少需要
回声。并且不要忘记设置
$this->请求->响应
阿贾克斯方法。
project URIs. Or you will modify all
of your views after changing in routing rules.
basic controller class - it will be
parent class for all other
controllers.
Request::factory()->execute()->response()
returns string, so you need at least
echo
. And dont forget to set$this->request->response in your
ajax method.