Stuck with BS modal

14 views
Skip to first unread message

12u...@gmail.com

unread,
Mar 25, 2022, 9:32:52 AM3/25/22
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hi folks,

I have a login page which need to call for a captcha modal (separated module, captcha is my own) when the login page "sign-in" button is hit, but I'm stuck at this point w/ several things and questions - the captcha will be used from several pages of the app :

* I must process the 2 captcha buttons "renew" & "submit" from the login page :

        a)- when hitting the "renew" button, why is it the login event that is triggered instead of the captcha one ? (wild guess : because a modal is a HTML part and not a page ?)

        b)- the "renew" button event does 2 things : closing the captcha and calling it again, but it doesn't work : it is closed but not re-launched, why is that ? (not any msg on the console and a ?PRINT() show the re-launch is executed)
        b2)- more strange, if I add an intermediate function into the captcha module that just call it and replace the captcha new call in the login page  btn event, it fail with this error msg :
{error,postback_request,
    {url,"localhost:8080/login"},
    {error,undef,
        [{captchb,renew,[],[]},
         {wf_core,run_websocket,1,[{file,"src/wf_core.erl"},{line,81}]},
         {nitrogen,ws_message_catched,1,[{file,"src/nitrogen.erl"},{line,69}]},
         {nitrogen,ws_message,3,[{file,"src/nitrogen.erl"},{line,59}]},
         {cowboy_simple_bridge_anchor,websocket_handle,2,
             [{file,
                  "src/cowboy_bridge_modules/cowboy_simple_bridge_anchor.erl"},
              {line,70}]},
         {cowboy_websocket,handler_call,6,
             [{file,"src/cowboy_websocket.erl"},{line,482}]},
         {cowboy_http,loop,1,[{file,"src/cowboy_http.erl"},{line,231}]},
         {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}}
         {proc_god_survey,check_jesses_work,1,[{"Jesse is not working enough}"]}

        c)- consequence of the 2 above questions, shall I move all the captcha mechanics into the login page, meaning I'll be obliged to repeat that for each and every page calling a captcha, which doesn't look very right ?

        d)- as it seems I don't have another solution than to loop the captcha from within itself, won't it create a memory leak, especially if the answer's wrong, in which case it'll redirect to the index page (or will it be GC as usual) ?

Jean-Yves


BTW, I modified coldstrap.erl to add another property (not closing it automatically when the user is clicking out of it or hit the escape key), it may be a good idea to add that to the next version (?) :
modal_body(Modalid, Title0, Body0, Footer0, Options) ->
    HasXButton = proplists:get_value(has_x_button, Options, false),
    %% ADDED: Forbid modal closure by clicking outside of it or hitting ESC
    HasDontCloseFromOutside = proplists:get_value(has_dont_close_from_outside, Options, false),
    DontCloseFromOutside = case HasDontCloseFromOutside of
        false  -> ""
        ; true -> "data-backdrop='static' data-keyboard='false'"
    end,
    %% /ADDED
    XButton = format_x_button(HasXButton),
    Title   = modal_header(Title0),
    Footer  = modal_footer(Footer0),
    %% ORG line replaced & move out of the way
    %%%%"<div class='modal fade' id=">>,Modalid,<<"role=dialog>
    [<<
        "<div class='modal fade' id=">>,Modalid,<<" role=dialog ">>,DontCloseFromOutside,<<">
[…]

12u...@gmail.com

unread,
Mar 25, 2022, 11:51:06 PM3/25/22
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hehe, you're never better served than by yourself, although it can take "some" time.

I had forgotten about the "delegate=?MODULE" option that allows to force the event to be processed by it's module, and I solved the image renewing by creating a another list of them, setting it in new #image{…} and replacing those on the screen by the set of new one (new list + replacement called by the "renew" button event :)

Thanks Jean-Yves, you where very helpful ! \o/ ;-p)

Jesse Gumm

unread,
Mar 28, 2022, 11:58:16 AM3/28/22
to nitrogenweb
Hi Jean-Yves,

Thanks for the follow-up and I'm glad you solved it.

If you want to submit a pull request to coldstrap, please do so, I'm happy to merge any of those.  Coldstrap gets filled in so slowly because I only add what I need when I need it, but I'm happy to flesh it out more fully.

-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 view this discussion on the web visit https://groups.google.com/d/msgid/nitrogenweb/48581103-881e-49c3-a2d7-8cff8b18d889n%40googlegroups.com.


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

12u...@gmail.com

unread,
Mar 28, 2022, 12:20:38 PM3/28/22
to Nitrogen Project / The Nitrogen Web Framework for Erlang
Hi Jesse,

Hmm, I have to document myself about pull requests, 'cos if I (almost) understand what it is, I don't know how it really works (well, my understanding of git is quite limited).
If you have URLs about that, I'll take them :)

Jean-Yves
Reply all
Reply to author
Forward
0 new messages