JQuery overlay / alert without .onclick event - php responder?

I have no experience with jquery or javascript. I am trying to implement this technique to respond to user requests for errors or messages in general.

lights-out-dimmingcovering-background-content-with-jquery

This method uses the onclick event and not what it is after, I tried replacing .onclick with .load, but this does not seem to work. I am fixing up quickly because I don’t have time to learn jquery or event handlers.

The goal is to catch any errors or message, and as soon as they are triggered, a warning window is called up without any further action, such as .onclick.

What my code looks like:

{PHP}
$forms = new forms();
if(count($forms->showErrors) > 0 // or == true)
{
    foreach($forms->showErrors as $error)
    {
        print('<p class="alert">'.htmlspecialchars($error, ENT_QUOTES).'</p>');
    }
}

Edit: ALL FIXED, thanks!

+1
1

".load", "" ( DOM , ), - Lights Out:

$(document).ready(function(){  

    //Adjust height of overlay to fill screen when page loads  
    $("#fuzz").css("height", $(document).height());  

    //When the link that triggers the message is clicked fade in overlay/msgbox  
    //$(".alert").click(function(){  
    //  $("#fuzz").fadeIn();  
    //  return false;  
    //});

    // INSTEAD: If any errors are present in the page, fade in the layer:
    if ( $("p.alert").length ) {
        $("#fuzz").fadeIn();
    }
    // end of change

    //When the message box is closed, fade out  
    $(".close").click(function(){  
        $("#fuzz").fadeOut();  
        return false;  
    });  

});  

//Adjust height of overlay to fill screen when browser gets resized  
$(window).bind("resize", function(){  
    $("#fuzz").css("height", $(window).height());  
});

HTML CSS .

+2

Source: https://habr.com/ru/post/1751844/


All Articles