在cakephp中的查询函数中传递参数 [英] passing parameters in query function in cakephp

查看:132
本文介绍了在cakephp中的查询函数中传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Jquery的初学者,我无法找到解决问题的方法.

I'm a beginner in Jquery and I cannot find out the solution to my problem.

在cakephp中,我有一个视图,可以通过以下方式调用我的jquery脚本:

In cakephp, I have a view where I call my jquery script in the following way:

<?php echo $this->Js->click; ?>

jquery函数如下

the jquery function is the following

$(function ()
    {
      $('#toogle-data').hover(function ()
      {
      $(this).toggleClass('Highlight');
      });


      $('#toggle-data').click(function ()
      {
        $("#more").hide();

        $(this).toggleClass("active").next().slideToggle("normal");
      });


     });

这很好.

但是当我想传递参数时,它不起作用

But when I want to pass parameter, it does not work

在视图中,我将上述调用替换为

in the view I replace the above call by

<?php echo $this->Js->click('#toggle-data'); ?> 

然后将我的jquery函数的第一行更改为以下内容

and I change the first line of my jquery funnction as the following

$(function (x)

我收到以下消息

JsHelper:: Missing Method click is undefined [CORE\Cake\View\Helper\JsHelper.php

感谢您的帮助

推荐答案

@ AD7six是正确的,因为click不是JsHelper的方法.

@AD7six is correct in that click is not a method of JsHelper.

您要实现的目标最好由来完成创建自己的助手.

What you're trying to achieve would be best done by creating your own helper.

使用您自己的助手,您可以创建一个返回click函数的方法.

With your own helper you could create a method that returns the click function.

这篇关于在cakephp中的查询函数中传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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