How to un-wire an element?

49 views
Skip to first unread message

Ramkrishna Kulkarni

unread,
Oct 18, 2011, 2:08:23 AM10/18/11
to nitro...@googlegroups.com
Hello again!

I keep adding a removing elements from the page. I get JS error on during validation if the removed elements were wired. How do I un-wire/unbind an event?

Thanks,
Ram

Jesse Gumm

unread,
Oct 20, 2011, 3:33:28 PM10/20/11
to nitro...@googlegroups.com
I'm going to look into this one.

I don't think there is a way to unwire an event right now, but I
have't dug through the code yet to find out.

-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/-/0MDPFY1jdGcJ.
> 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
Sigma Star Systems
414.940.4866
gu...@sigma-star.com
http://www.sigma-star.com

Marc Worrell

unread,
Oct 20, 2011, 3:39:37 PM10/20/11
to nitro...@googlegroups.com
When Nitrogen hasn't been changed since I looked into it then it uses LiveValidation for the form validation.

LiveValidation keeps its own data structure with references to the to be validated form elements.
Kind of double administration.

In Zotonic we changed this, so that LiveValidation will fetch the validation from the DOM and not from its own data structure.
You can check our code, it shouldn't be too hard to port our changes to Nitrogen.

- Marc

Jesse Gumm

unread,
Oct 20, 2011, 3:41:32 PM10/20/11
to nitro...@googlegroups.com
I'll have to give that a looksee, thanks Marc.

I've also been planning on borrowing some of your smtp support as well :)

-Jesse

Marc Worrell

unread,
Oct 20, 2011, 3:55:06 PM10/20/11
to nitro...@googlegroups.com

On 20 okt 2011, at 21:41, Jesse Gumm wrote:

> I'll have to give that a looksee, thanks Marc.
>
> I've also been planning on borrowing some of your smtp support as well :)

You are more than welcome.
Mail the list or me when you have any questions.

Good to see both projects advance.

- Marc

Jesse Gumm

unread,
Oct 20, 2011, 3:58:38 PM10/20/11
to nitro...@googlegroups.com
Will do. Thanks a ton Marc!

-Jesse

Jeremy Raymond

unread,
Oct 22, 2011, 9:39:05 AM10/22/11
to nitro...@googlegroups.com
Someone asked the same question on SO. The response indicated there's no way to do it directly in Nitrogen, but you can via javascript.

Jeno I. Hajdu

unread,
Feb 26, 2012, 5:27:08 PM2/26/12
to nitro...@googlegroups.com
Hi,

Jesse, have you looked into this (the LiveValidation part and incorporating the Zotonic changes) eventually?

I have run into a problem where validation is not working on dynamically added textboxes and
I thought the root cause of the problem could be the same. I was wondering whether anyone looked
into it deeper or started working on it, otherwise I might do that.

Regards,
Jeno

Jesse Gumm

unread,
Feb 27, 2012, 1:55:52 PM2/27/12
to nitro...@googlegroups.com
Hi Jeno,

I have not yet had a chance to play with incorporating Zotonic's
validation methods.

I definitely encourage you to take a crack at it.

-Jesse

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

Jeno I. Hajdu

unread,
Mar 14, 2012, 3:24:10 AM3/14/12
to nitro...@googlegroups.com
Hi,

I have looked into this, did some tracing on the Erlang side and also looked at the JS side
with Firebug (I am using a recent version of Firefox). I am a bit stuck now.
At least at the moment and for my problem (adding dynamically validators which are totally
ignored) I am not convinced the problem is with LiveValidation.
The list of validators are stored in the state handler which gets serialized and pushed
to the DOM as part of pageContex in Nitrogen.$params and gets deserialized and reused when
handling a user's activity.
What I see is that at one point for some reason the pageContext gets stuck.
The Erlang traces clearly show that the right context gets 'pickled' (base64 encoded) and
serialized, the proper Nitrogen.$set_param for pageContext is there in the HTTP response
according to Firebug, but if I look at the DOM the old pageContext is stored.
And further Erlang traces of deserialization and 'depickling' show that the same, outdated
pageContext gets resent everytime from that on, even though the Erlang side keeps
pushing newer and newer context.
As the old, stuck context only has the validators added initially and not the new ones,
those are not used at all.

Has anyone seen similar problems? Any idea on how to carry on with the browser/JS
side of debugging? Up until now I only used Firebug there (and Error Console of course,
which haven't showed any errors), is there any other JS debug tools I should use
in addition? I use Firefox 10.0.2, but had the same issue with some other recent Firefox
versions (I haven't looked at other browsers yet, but will do that now).

I am stuck because Nitrogen's Erlang code seems to be doing the right thing, also
the JS side seems to be OK too (in this regard it's a simple assignment operation and
it works till a point, which seems to be a deterministic point btw).

Any idea, advice is more than welcomed!

Thanks and BR,
Jeno

Jeno I. Hajdu

unread,
Mar 14, 2012, 3:39:30 AM3/14/12
to nitro...@googlegroups.com
Hi again,

same result with Chromium. Also I forgot to mention that I initially used Inets under Nitrogen and
switched to Mochiweb recently, seen this problem in both cases.

BR,
Jeno

Jesse Gumm

unread,
Mar 15, 2012, 2:17:20 PM3/15/12
to nitro...@googlegroups.com
Very interesting find, Jeno.

So it's sending the context but for whatever reason Nitrogen.js isn't
saving the context and therefore resending the original context back
to the server? It honestly sounds to me like that might be unrelated.
I've not looked too deeply into the context transfer along with the
pickling and depickling that goes along with it as up until now, it
has Just Worked (TM). I wonder if these two issues aren't unrelated.
It seems to be to be the case that they *are* unrelated, just two
separate issues.

I say this because I've not had problems dynamically adding new
validators to new elements. The problem encountered, as I understand
it, is the ability to remove a validator from an object, or in some
cases, for the validators to break if one of the elements targeted by
a validator is removed.

But I can do some tracing myself to see why it might not be storing
the new context. That's odd, to say the least.

-Jesse

Jeno I. Hajdu

unread,
Mar 15, 2012, 4:07:54 PM3/15/12
to nitro...@googlegroups.com
Hi,

I agree that the problems are probably unrelated. Initially I thought that what Marc
has mentioned about LiveValidation could be the single source of both problematic
scenarios, but now as I see that my problem stems from the context transfer the
two seems to be unrelated (of course once I get past the context transfer problem
I might face another problem due to LiveValidation's mentioned double administration).

My problem still looks strange, because it consistently fails seemingly regardless of
chosen browser or underlying web server. So it's either a nitrogen fault or my own
app's fault, but because my scenario would be quite common (dynamically adding form
elements and validations for those) and noone has complained on the list that this does
not work I would opt for this being my fault. I'll keep looking anyway and if I find
something interesting, I'll share it here.

BR,
Jeno
Reply all
Reply to author
Forward
0 new messages