Search code examples
javascripttwitter-bootstrapflaskpromptbootbox

Bootbox: how to add a 'prompt'


would you be so kind to enlighten me; i have the following issue

in jcertify.html there is :

<!-- Bootbox utilities 
    ================================================== -->
    <script src"../static/assets/js/email_sign_up.js"></script>
  </body>

in email_sign_up.js there is :

function    emailSignUp( )
{
    bootbox.prompt("<strong>Email address</strong>Enter email address where the report should be send to : ", function(result)  {                
        if (result) {   
            // Example.show("email: <b>"+result+"</b>");    
            console.log("NikoS");
        } 
    });
}

in jcertify.html it is like :

<p><a href="javascript:console.log('hi there');emailSignUp();" class="bb-trigger btn btn-primary btn-lg btn-block">Sign up</a></p>

in the browser's debugger, when i click on the "Sign up" button what i see is :

[Log] hi there (jcertify, line 1) [Error] ReferenceError: Can't find variable: emailSignUp global code (jcertify, line 1)

do you have any idea what i am doing wrong ?


Solution

  • $(document).ready(function()    {
    
        $(document).on("click", "#signin_session", function(event)  {
            event.preventDefault() ;
    
            bootbox.prompt("<strong>Email address</strong><br>Please enter the email address where the report should be send to : ", function(email_address)  {
                    if (email_address)  { 
    
                        formulate           = {'email_address': email_address} ;
                        $.ajax({
                            url:            "/jcertify/session-report/",
                            data:           JSON.stringify(formulate,null), // {'email_address': email_address},
                            type:           "POST",
                            contentType:    "application/json;charset=UTF-8",
                            success:        function(response) { document.write(response) ; },
                            error:          function(error) { console.log(error) ; }
                        });
    
                    }
            });
    
        });
    });