[Kss-devel] Trigger event manually
Balazs Ree
ree at ree.hu
Wed Oct 31 17:14:50 CET 2007
On Wed, 31 Oct 2007 16:26:49 +0200, Hedley Roos wrote:
> Let's say I have a piece of javascript that does something like
>
> """
> mybutton.onclick();
> """
>
> mybutton has an event attached to it thanks to my KSS rule:
>
> button#someid:click {
> etc etc etc
> }
>
> I want the azax event handler to also fire, but it does not since events
> are not generated when doing a click through Javascript.
>
> Question: how do I force that event to fire?
>
> I've been through kukit.js and it seems that in one of the rules or
> rule_processors arrays lies the callable objects. Is this correct?
There is no way of firing a browser event manually. There will however be
a way of firing all the actions bound by a given kss rule, on a given
node (which ends up at the same result).
Currently the following methods can be used. They are both methods on an
_event binder_ instance in javascript.
binderinstance.__continueEvent__(eventname, node, defaultParameters)
This executes the actions bound on the binder instance, for the given
eventname, on the given node.
binderinstance.__continueEvent_allNodes__(eventname, defaultParameters)
This executes the actions bound on the binder instance, for the given
eventname, on all the nodes bound in this instance.
These were made to cover use cases for continuation events. There are
examples in kss.demo for this as well as in the upcoming
kss.plugin.livesearch plugin. There are also some comments to explain the
call signature of these methods in the eventreg.js file.
There is currently no commodity method for calling up all the events on
all the necessary binder instances (or on the singleton binder instance
as in case of click), on a given node - this is what you would like to
have. We will take care of providing a clean API for this task in the
next version of kss.
I cannot go into deeper explanation here about what an event binder
instance is or how you would look it up from the registry. I will,
however, try to write a small recipee page on kssproject.org about this,
which will enable you to use this even before the cleaner API arrives. No
deadline promised though.:(
Best wishes,
--
Balazs Ree
More information about the Kss-devel
mailing list