I just can't seem to get my head wrapped around this... I have a few questions, please bear with me! :)
First, the se开发者_运维知识库tup:
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
- Use reverse routing to generate project URIs. Or you will modify all of your views after changing in routing rules.
- Extend Controller_Template in your basic controller class - it will be parent class for all other controllers.
Request::factory()->execute()->response()
returns string, so you need at leastecho
. And dont forget to set $this->request->response in your ajax method.
精彩评论