Cakephp JsHelper添加/删除类 [英] Cakephp JsHelper add/remove Class

查看:98
本文介绍了Cakephp JsHelper添加/删除类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的问题,但我还没有能够找到在线的答案,或在这里stackoverflow。如何将另一个函数附加到Js事件调用。这是我有,应该给一些上下文:

this is a simple question, but one that I have not been able to find an answer to online, or here on stackoverflow. How do I attach another function to a Js event call. This is what I have and should give some context:

$this->Js->get('#all-matches');
$this->Js->event(
'click', 
    $this->Js->request(
        array('action' => 'findMatches', 'all'),
        array('async' => true, 
              'update' => '#matches', 
              'success' => $this->Js->each('$(#event-matches).addClass("active");'))

我基本上想在ajax调用之后将一个div元素的类名改为active。看起来这应该是一个没有脑子的,但我找不到任何文档。

I essentially want to change a classname on a div element to 'active' after the ajax call. Seems like this should be a no-brainer but I cant find any documentation on it.

谢谢!

推荐答案

Js助手功能有限,一个简单的php包装器生成所有类型的js代码你需要的sooner或更高版本,你会发现它在你的方式,而不是帮助你的代码更快,你现在已经做了。最好是直接编写jquery代码自己(或任何其他你选择的js库)。

The Js helper is limited in feature. Can't really expect a simple php wrapper to generate all types of js code you need. Sooner or later you will find it getting in your way rather than helping you code faster as you have done now. It's best to just directly write jquery code yourself (or any other js lib of your choice).

这篇关于Cakephp JsHelper添加/删除类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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