Add Flash Notification After Create or Update Actions in Laravel Applications

In header,
/assets/js/aceplus.backend.functions.js
(and)

$(document).ready(function() {
App.init();
TableManageTableTools.init();

//check for notification
@if(Session::has(‘message’))
var message_title = “{{Session::get(‘message’)[‘title’]}}”;
var message_body = “{{Session::get(‘message’)[‘body’]}}”;
setTimeout(addNotification(message_title, message_body), 5000);
@endif

//set time out for the flash message..
setTimeout(function(){
$(‘#flash-message’).hide(“slow”);
}, 2000);
});

———————————————————————————————————————–

In aceplus.backend.functions.js, //need this js
function addNotification(title, text){
$.gritter.add({
title: title,
text: text,
time: 3000
});
return false;
};

————————————————————————

In index.blade.php, under header,
@if(count(Session::get(‘message’)) != 0)

@endif

————————————————————————

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s