无法从 cakephp 观察字段获取价值
我一直在尝试将分页值从选择框传递到我的一个控制器以进行分页 我想通过 ajax 来做到这一点,所以我使用 cakephp 观察字段。 我的代码如下:
$options = array('10' => '10', '20' => '20', '50' => '50', '100' => '100');
echo $form->input('pagecount', array(
'id' => 'pagecount', 'name' => 'pagecount', 'type' => 'select',
'options' => $options, 'selected' => '10', 'div' => false, 'label' => false
));
echo $ajax->observeField('pagecount', array(
'with' => '$F("pagecount")', 'url' => array(
'controller' => 'templates', 'action' => 'themes', $template_id
), 'update' => 'themeTable', 'indicator' => 'loaderIDast'
));
问题是我无法获取我在observeField的url参数中提到的控制器中所选选项的值。我已使用observefield的with参数我可以在我的 Firefox 网络面板的参数选项卡下看到所选的值。
I have been trying to pass paging value from a select box to one of my controller for paging
I want to do this by ajax so i used cakephp observe field.
My code is as follows:
$options = array('10' => '10', '20' => '20', '50' => '50', '100' => '100');
echo $form->input('pagecount', array(
'id' => 'pagecount', 'name' => 'pagecount', 'type' => 'select',
'options' => $options, 'selected' => '10', 'div' => false, 'label' => false
));
echo $ajax->observeField('pagecount', array(
'with' => '$F("pagecount")', 'url' => array(
'controller' => 'templates', 'action' => 'themes', $template_id
), 'update' => 'themeTable', 'indicator' => 'loaderIDast'
));
Problem is that i cannot get the value of the selected option in the controller that i have mentioned in the url param of the observeField.I have used the with param of the observefield for this.I can see the selected value under the parameters tab of my firefox net panel.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的语法暗示 Cake 1.2,但您的问题标记为 1.3。你用的是哪个?
Ajax 助手在 Cake 1.3 中已被弃用,并且功能充其量也很危险。其大部分适当的功能已移植到 Js 帮助程序或 Html/Form 帮助程序。
observeField
方法已弃用,并且在 Js 帮助器中没有同义词。如果我的猜测是正确的并且您正在使用 Cake 1.3,那么我的建议是,只需用普通 javascript 写出客户端观察者,然后将结果传递回服务器端代码,以同样普通的方式进行处理。无论如何,花哨的代码片段生成并不适合一次性或高度可变的情况,它并没有真正干掉任何东西(这是 Js 帮助器的要点。)大多数情况下,它只是引入了几个额外的层当您尝试调试时会变得复杂。
HTH。 :)
Your syntax implies Cake 1.2 but your question is tagged with 1.3. Which are you using?
The Ajax helper is deprecated in Cake 1.3 and functionality is dodgy at best. Most of its appropriate functionality was ported to the Js helper, or the Html / Form helpers. The
observeField
method is deprecated and does not have a synonym in the Js helper.If my guess is right and you're using Cake 1.3, my suggestion would be, just write out the client-side observer in ordinary javascript and pass the result back to your server-side code for processing in the likewise ordinary manner. Fancy generation of code snippets is not really suitable for one-shot or highly mutable situations like this anyway, it doesn't really DRY up anything (which is the main point of the Js helper.) Mostly it just introduces a couple of extra layers of complexity when you're trying to debug.
HTH. :)
Ajax 助手在 Cake 1.3 中已被弃用,并且功能充其量也很危险。其大部分适当的功能已移植到 Js 帮助程序或 Html/Form 帮助程序。 observeField 方法已被弃用,并且在 Js 帮助器中没有同义词。
The Ajax helper is deprecated in Cake 1.3 and functionality is dodgy at best. Most of its appropriate functionality was ported to the Js helper, or the Html / Form helpers. The observeField method is deprecated and does not have a synonym in the Js helper.