Code

Discussion on Flat, Modern Notifications

Discussion on Flat, Modern Notifications

Cart 59 sales

gigazong supports this item

Supported

21 comments found.

Howdy,

These look excellent!

I have a question though and I know this is outside what you’re offering, however is key to being able to implement them.

If these were used to add notifications to a site for example, can you point me in the direction of how such a notification(s) could be triggered only the once, then say recorded as either a cookie or update a MySQL db entry?

Matt

Hey Matt,

thanks for your question.

Using a cookie to figure out if a notification has already been shown should be rather simple. Since you’re loading up jQuery anyways, I’d recommend using a small, free plugin called jquery-cookie. You can get it over on this github repository, along with an in-depth documentation.

Basically, you would check if a cookie is present before you fire the notification. If the cookie is not present, you fire the notification and set the cookie, so that the notification won’t be shown the next time. Using jquery-cookie, you could write, for example:

if( $.cookie('notification_shown') == false) {
  fireNotification();
  $.cookie('notification_shown', '', { expires: 356 });
}

If you prefer using pure JavaScript, you can of course do that, too. Here’s a great article on MDN on this topic.

Unfortunately, I can’t really answer your question concerning updating a database after firing a notification, as I’m not really a backend developer.

I hope I was able to help you with this answer.

best, max.

by
by
by
by
by
by

Tell us what you think!

We'd like to ask you a few questions to help improve CodeCanyon.

Sure, take me to the survey