views:

84

answers:

1

In Nitrogen, the Erlang web framework, you wire actions like this:

wf:wire(send_message, #event { type=click, postback=send_message })

but if after that you run

wf:wire(send_message, #event { type=click, postback=send_message2 }),

then you get the action wired twice.

How do you unwire the previous action or all actions of an element?

+1  A: 

Since events in nitrogen are bound using jquery's bind method. You can use unbind to unbind them. There isn't currently a nitrogen api to unbind an event but you could output the javascript code to unbind it yourself if you so wished.

see action_event.erl for an example of how the binding javascript is output. You can create a similar action/event that removes the binding.

Jeremy Wall
I should add that I have never ran into a case where I actually needed to unbind an action in Nitrogen and I've written one of the more complex apps I've seen as far as event handling and custom elements go. What exactly are you needing this functionality for?
Jeremy Wall
My problem is described here: http://groups.google.com/group/nitrogenweb/browse_thread/thread/c6d9927467e2a51aI'll try to turn that into a stack overflow question.
J. Pablo Fernández
Jeremy, thanks for the answers. Here's the question in SO: http://stackoverflow.com/questions/1994490/how-to-keep-track-of-a-process-per-browser-window-and-access-it-at-each-event-in
J. Pablo Fernández