, , , , status true false.
When a user sends a new message, you add it to the database with the false status. this means that the user no longer sees the message.
in your code we add a new attribute for the link <a>asnotification
<a id="resource-button" notification="4" href="#" data-role="button" data-icon="info" data-iconpos="left">Resources</a>
in this case we have 4 new notifications for the user.
First of all, we need to check if the notification attribute exists or is not equal to 0, then we do the notifi field.
$(document).ready(function() {
if( $("#resource-button").hasAttr("notification")) {
var num = $("#resource-button").val("notification") ;
if (num > 0) {
$("#number").css("display", "block") ;
$("#number").text(num);
}
}
});
CSS for #number:
#number {
height: 18px;
width: 18px;
background: url("../images/notification-bg-clear.png") no-repeat scroll center center #F56C7E;
position: absolute;
right: 5px;
top: -10px;
color: #FFF;
text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.2);
text-align: center;
font-size: 9px;
line-height: 18px;
box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.17) inset, 0px 1px 1px rgba(0, 0, 0, 0.2);
border-radius: 9px;
font-weight: bold;
cursor: pointer;
}
source
share