JQuery arka bindirme / uyarı onclick olay olmadan - php cevap.?

1 Cevap php

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

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

Bu yöntem, onclick olayı kullanır ve bundan sonra, ben yerine denedim ne im değil. Onclick. Yüküyle ama çalışmak için görünmüyor. Gerçekten Jquery veya olay işleyicileri öğrenmek için zaman yok gibi hızlı bir düzeltme peşindeyim.

Amaç herhangi bir hata veya mesaj en yakalamak ve bu denir kez uyarı kutusu gibi onclick. Gibi başka eylemler olmadan denir.

Nasıl benim kod görünecektir:

{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 Cevap

Sen ". Yük" ile doğru yoldayız ancak sayfanın "hazır" olay bu işlevselliği bağlamak istediğiniz (DOM tamamlandığında, siz yük olay beklemek gerekmez), yani burada değiştirmek gerekir - ne Lights Out sayfasındaki kod örneği kullanarak varsayarak:

$(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());  
});

Çok katman için HTML ve CSS dahil emin olun.