public
Description: Nitrogen Web Framework for Erlang
Home | Edit | New

delagate to catch submodule events

if you use a template which calls a module (I will refer this as submodule), rather than the page itself
(see example below) and you try to use events on the submodule, the
events will go to the page:event function. if you want to handle the
events in the submodule you should delegate the event to the module.
for example:

i have a template which call the page module (normal usage), and
another module which i use on all my pages:



[[[page:body()]]]
[[[another_module:render()]]]


and the another_module have a button in it, which i want to work on
all the pages that use it.
so if i just add on another_module:render/0 the button:

#button{id=btn, text=“Do Domthing”, postback=do_something}

the callback to the event function will be done by nitrogen on the
master web page module (‘page’) and not on the another_module:event
function.
if you want to set it to be sent to the another_module, use:

#button{id=btn, text=“Do Domthing”, postback=do_something}

wf:wire(btn, #event{type=click, delegate=?MODULE, postback=
do_something}),

Last edited by waltaskew, Sun Oct 25 12:10:26 -0700 2009
Home | Edit | New
Versions: