Javscript problem.

27 views
Skip to first unread message

Stuart Thackray

unread,
Feb 3, 2016, 3:45:48 AM2/3/16
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hi, 

I have a problem or lack of understanding about what is possible. I want to do something similar to https://api.jquery.com/attribute-ends-with-selector/ in a postback that is set all the elements ending in start_date with a value.

Attached is a test module; any assistance would be appreciated.

Regards,
Stuart



test_datesetter.erl

Stuart Thackray

unread,
Feb 3, 2016, 4:53:14 AM2/3/16
to Nitrogen Project / The Nitrogen Web Framework for Erlang
I hadn't set the html_name for the pure javascript button to work. I am still interested if there was a using nitrogen to achieve the same.
test_datesetter.erl

Jesse Gumm

unread,
Feb 4, 2016, 5:44:53 PM2/4/16
to nitrogenweb
Hey Stuart!

So Nitrogen's wiring uses jquery selectors to determine what elements
to specify.

But Nitrogen makes one assumption which is that selectors that start
with an alphanumeric are assumed to be IDs.

So if you did something like:

wf:set(".textbox[name$='start_date']", "some value").

That *should* work.

That said, the logic about whether or not a selector is treated as a
nitrogen element is a little wonky:
https://github.com/nitrogen/nitrogen_core/blob/master/www/nitrogen.js#L783

It should probably just be changed to be a regular expression checking
for only alphanumerics and if so, then it's an ID, otherwise, it's a
selector.

With that change, rule six should work without problem.

-Jesse
> --
> You received this message because you are subscribed to the Google Groups
> "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nitrogenweb...@googlegroups.com.
> To post to this group, send email to nitro...@googlegroups.com.
> Visit this group at https://groups.google.com/group/nitrogenweb.
> For more options, visit https://groups.google.com/d/optout.



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

Stuart Thackray

unread,
Feb 5, 2016, 2:36:27 AM2/5/16
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Thanks very much Jesse,

I know understand where I was going wrong; and the below correctly sets the inputs.

wf:set(".textbox[name$=\\'start_date\\']", "16-02-03").

Thanks,
Stuart

Jesse Gumm

unread,
Feb 5, 2016, 9:50:12 PM2/5/16
to nitrogenweb
Excellent. But that does point out a problem. The target and trigger
(if set manually using a selector) should very well be js escaped.
Looks like I'll have to tweak that a bit so that you don't have to
escape it like that.

-Jesse

On Fri, Feb 5, 2016 at 1:36 AM, Stuart Thackray
Reply all
Reply to author
Forward
0 new messages