Personal tools
You are here: Home   Bugs   Calling javascript functions  
 
Document Actions

#3 — Calling javascript functions

State Rejected
Release:
Area Client side framework and general
Issue type Feature
Severity Medium
Submitted by Danny Bloemendaal
Submitted on 2007-06-25
Responsible Balazs Ree
Target release:
Return to tracker
Last modified on 2007-06-27
I'm looking for a way to be able to do things like the following:

Suppose you have a collapsable portlet or div. It's quite easy to create some kss that deals with the behavior. However, I want to make the collapsable state of the portlet persistent. The easiest way to do this is by using a client cookie. So, before kss I wrote a js function that saved the states of the collapsibles in a cookie and a js that read the cookie onload and set the portlets to the desired state. No rocket science.

Now.. how can we do this with kss? In many situations I can imagine that you just want to do something extra after (or maybe before) an event handler is processed. Is it possible to be able to define a post-process action? Something like:

#twistie img:click {
  action-client: toggleClass;
  toggleClass-kssSelector: parentnode("div");
  toggleClass-value: collapsed;
  postProcessFunction: storeCollapsible(...);
}

Of course, you need to be able to access the event node in storeCollapsible or pass it along.

And of course:

document:domReady {
  callFunction: restoreCollapsibles();
}

Or something like that.
Added by Balazs Ree on 2007-06-27 15:42
Issue state: unconfirmedrejected
Responsible manager: (UNASSIGNED)ree
There has been lots of argument on this issue and the general consensus is thio:

We do not want to allow an action that can callout to an arbitrary javascript function. The reason is that we feel it would bring us further away from the original goals of kss, would make the code less debuggable and less reusable.

Naturally, nothing prevents you from implementing callFunction if you wish to do so. However the suggested way is, that instead of allowing a way of generic callout, you register each javascript function you want to call as kss actions. After having done this, you would use it like:

document:load {
   action-clent: restoreCollapsibles;
}

We are applying the same pattern succesfully in the plugins of plone.app.kss.

I reject this issue now but if you beleive it's important to bring it up on the mailing list later, feel free to do so.
Added by (anonymous) on 2007-06-27 18:53
Well, then what about making a configlet or something where you can easily register your own functions instead of doing this in javascript yourself. That also makes it independent of the current kukit implementation since the registry will generate the proper js code to register your functions in the proper way.