Snackbar/Toast In VF Page

Snackbar/Toast In VF Page


Code:
 <apex:page id="page" docType="html-5.0" standardStylesheets="true" showHeader="false" sidebar="false" applyHtmlTag="true" Controller="HHNGroupOrdercontrollerAlert">
<html xmlns="http://www.w3.org/1999/xhtml">
            <head>         
<style type="text/css">
                        #snackbar {
            visibility: hidden;
            min-width: 250px;
            margin-left: -125px;
            background-color: #333;
            color: #fff;
            text-align: center;
            border-radius: 2px;
            padding: 16px;
position: fixed;
z-index: 1;
left: 50%;
bottom: 600px;
font-size: 17px;
}
#snackbar.show {
visibility: visible;
          -webkit-animation: fadein 0.5s, fadeout 0.5s 3.5s;
           animation: fadein 0.5s, fadeout 0.5s 3.5s;
}
@-webkit-keyframes fadein {
from {bottom: 0; opacity: 0;} 
to {bottom: 300px; opacity: 1;}
}
@keyframes fadein {
from {bottom: 0; opacity: 0;}
to {bottom: 300px; opacity: 1;}
}
@-webkit-keyframes fadeout {
from {bottom: 300px; opacity: 1;} 
to {bottom: 0; opacity: 0;}
}
@keyframes fadeout {
from {bottom: 300px; opacity: 1;}
to {bottom: 0; opacity: 0;}
}
   </style>
   <script>
            function myFunction() {
                        var x = document.getElementById("snackbar")
                        x.className = "show";
                        setTimeout(function(){ x.className = x.className.replace("show", ""); }, 4000);
}
</script>
</head>
<body>
<apex:form>
                        <div id="snackbar">  Error </div>
<apex:commandButton action="{!saveRec}" status="disablebtn" disabled="false" value="Submit" rerender="CustomerForm,td,dm" id="submit55"  oncomplete="myFunction()"/>
</apex:form>
</body>
</html>
</apex:page>

Result:

P.S: Comment Below for any Clarification or help!!
Happy working!! :) :) 

Comments

Popular posts from this blog

Embed Special Characters in VF Page

Some Common Errors in the Visual flow

Error: Compile Error: Illegal conversion from String to System.PageReference