The element you want to add an event to needs an id:
<metal:block macro-define="demo">
Content for macro that will be replaced with your event.
</metal:block>
<input type="text" id="document-title"/>
<input type="submit" id="document-submit" value="Submit"/>
You need to a KSS stylesheet, so create a file called sample.kss:
input#document-submit:click {
evt-click-preventdefault: True; # this prevents the button click event
action-server: response;
submit-title: currentFormVar('document-title');
}
Register your kss file as a resource:
<browser:resource
file="browser/sample.kss"
name="productname.sample.kss"
/>
Register your kss file with the kss registry in your GenericSetup? profile (profiles/default/kssregistry.xml) :
<?xml version="1.0"?>
<object name="portal_kss" meta_type="KSS Registry">
<kineticstylesheet cacheable="True" compression="safe" cookable="True"
enabled="1" expression=""
id="++resource++productname.sample.kss"/>
</object>
Create the browser view with response method:
from plone.app.kss.plonekssview import PloneKSSView
from kss.core import kssaction
from datetime import datetime
class DemoView(PloneKSSView):
@kssaction
def response(self, title):
# render a macro
content = self.macroContent('template/macros/demo')
# KSS specific calls
core = self.getCommandSet('core')
core.replaceInnerHTML('#portal-siteactions', content)
More here:
- http://kssproject.org/docs/tutorial/simple-kss/begin-with-kss.rst
- http://codespeak.net/svn/kukit/docs/introducing_kss/trunk/3-shipped-kss-plugins.txt






