Cakephp JsHelper添加/删除类 [英] Cakephp JsHelper add/remove Class
问题描述
这是一个简单的问题,但我还没有能够找到在线的答案,或在这里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屋!