Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

wf:wire()-ing an on click #event{} causes the event not to fire

#53

Here is a fairly minimal example:

-module(test).
-include_lib ("nitrogen/include/wf.hrl").
-compile(export_all).

main() -> #template{file="./site/templates/template.html"}.

body() ->
    PanelId=wf:temp_id(),
    [#link{text="Add", postback={add, PanelId}},
    #panel{id=PanelId}].

event(click) ->
    io:format("click~n");

event({add, PanelId}) ->
    Id = wf:temp_id(),
    wf:wire(Id, #event{type=click, postback=click}),
    wf:update(PanelId, #link{id=Id, text="Click"}).

In Nitrogen 1.0, if you click Add and then Click, the server prints "click".

In Nitrogen 2.0, the postback is no longer triggered in this case, though I think we would expect it to be.

Instead we can do

event({add, PanelId}) ->
    wf:update(PanelId, #link{text="Click", actions=#event{type=click, postback=click}}).

And it does work in Nitrogen 2.0. The two should function equivalently, though.

Reported by Brian O · April 22nd, 2010 @ 04:56 PM

State: new
Milestone: none
Assigned to: nobody

Activity

  1. Rusty Klophaus
  2. Rusty Klophaus
    Rusty Klophaus
    • Milestone cleared.
    • Milestone order changed from 0 to 0

    June 29th, 2010 @ 08:00 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.