Alternate link postback wiring

60 views
Skip to first unread message

Jeremy Raymond

unread,
Apr 13, 2012, 1:34:33 PM4/13/12
to nitro...@googlegroups.com
From what I can tell Nitrogen wires link post backs by running some JavaScript on the client when the page loads. I have some pages with hundreds of links that have postback and it's hella slow on IE.  Is there any alternate way to wire the postbacks (maybe hard wire it somehow in via a script action on the link)?

Jesse Gumm

unread,
Apr 13, 2012, 11:01:26 PM4/13/12
to nitro...@googlegroups.com
Hi Jeremy,

It's definitely true that a lot of wiring like that can indeed slow it
down in a browser with a slower javascript engine.

I do think the best solution is something like a hard wiring event,
maybe a hard_events attribute that can attempt to intelligently assign
events to html onclick attributes and the like.

An alternative you could try to use without reworking the nitrogen
elements is to use the #api element and then make the links with
directly typed links.

IE

body() ->
wf:wire(#api { name=my_postback, tag=links }),
[
"<a href=\"javascript:;\"
onclick=\"page.my_postback('link1')\">Link 1</a>",
"<a href=\"javascript:;\" onclick=\"page.my_postback('link2')\">Link 2</a>"
].


api_event(my_postback, links, Args) ->
do_something_with(Args).

That's at least a way to avoid having to deal with the slowdown of
that many links and all the generated javascript associated with
wiring events, though I admit it's not exactly the most
straightforward approach.

-Jesse

> --
> You received this message because you are subscribed to the Google Groups
> "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/nitrogenweb/-/G_FHgZo9b0MJ.
> To post to this group, send email to nitro...@googlegroups.com.
> To unsubscribe from this group, send email to
> nitrogenweb...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nitrogenweb?hl=en.

--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Jeremy Raymond

unread,
Apr 16, 2012, 10:41:10 AM4/16/12
to nitro...@googlegroups.com
Hey Jesse,

Using #api{} for the postback works. It's simple enough for what I'm trying to do. Thanks a lot.

--
Jeremy


> For more options, visit this group at
> http://groups.google.com/group/nitrogenweb?hl=en.

Reply all
Reply to author
Forward
0 new messages