[Plone3.0] Some JS questions

Godefroid Chapelle gotcha at bubblenet.be
Mon Jun 18 08:16:35 UTC 2007


Andreas Jung wrote:
> Hi,
> 
> some questions about doing it the plone-ish way in Plone 3.0..
> 
> Clicking on a document action icon should trigger a JS method that performs
> two tasks:
> 
> - obtain the HTML code of the main slot
> 
> - send the HTML fragment through a async POST request back to Plone
> 
> It there some common API in Plone to perform both (Sarissa, KSS)?
> I know of course how to perform both task the traditional way but
> avoiding redundancies is a good idea.
> 
> Andreas

I am not totally sure I understand your question. I'll try to answer though.

With KSS, there would be two parts :

First, you'd need to add an event rule on the action in one of the 
existing Kinetic Stylesheets (plone.kss for instance), or add it in your 
own KSS resource. Something like :

#my-action:click {
     action-server: computeHTMLFragment;
}

This would ensure that when the HTML element with `my-action` id gets 
clicked, the server is notified at the `computeHTMLFragment` URL (this 
is obviously an identifier that you can choose freely).

Second, you'd need a Five view inheriting from `kss.core.KSSView` which 
would have a method registered with the name `computeHTMLFragment`.

Code would look like this :

from kss.core import KSSView

class MyView(KSSView):
     def computeHTMLFragment(self):
         fragment = computation()
         ksscore = self.getCommandSet('core')
         ksscore.replaceHTML('#html-element-to-replace', fragment)
         return self.render()

For more details, Balazs has written a lot of documentation that can be 
found at

http://kssproject.org/documentation/tutorials

HTH
-- 
Godefroid Chapelle (aka __gotcha)- BubbleNet  http://bubblenet.be





More information about the Product-Developers mailing list