On many websites, they show a new visitor landing on the page displayed in an alert Notification that pops up on the bottom right or left
The code below is working just fine, except I have not been successful in changing the message text which reads:
Turning standard Bootstrap alerts into awesome notifications
I want to change this line of text by a customized message but I cant find how to replace this hard coded message with a variable example:
var welcome = 'Welcome visitor from Australia'
;
<script type="text/javascript" language="JavaScript">
'use strict';
$(window).on('load', function() {
function notify(message, type) {
$.notify({
message: message
}, {
type: type,
allow_dismiss: false,
label: 'Cancel',
className: 'btn-xs btn-inverse',
placement: {
from: 'bottom',
align: 'right'
},
delay: 2500,
animate: {
enter: 'animated bounceInUp',
exit: 'animated bounceOutUp'
},
offset: {
x: 30,
y: 30
}
});
};
notify('Welcome to Notification page', 'inverse');
});
$(document).ready(function() {
function notify(from, align, icon, type, animIn, animOut) {
$.notify({
icon: icon,
title: ' Bootstrap notify ',
message: 'Turning standard Bootstrap alerts into awesome notifications',
url: ''
}, {
element: 'body',
type: type,
allow_dismiss: true,
placement: {
from: from,
align: align
},
offset: {
x: 30,
y: 30
},
spacing: 10,
z_index: 999999,
delay: 2500,
timer: 1000,
url_target: '_blank',
mouse_over: false,
animate: {
enter: animIn,
exit: animOut
},
icon_type: 'class',
template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-{0}" role="alert">' +
'<button type="button" aria-hidden="true" class="close" data-notify="dismiss">×</button>' +
'<span data-notify="icon"></span> ' +
'<span data-notify="title">{1}</span> ' +
'<span data-notify="message">{2}</span>' +
'<div class="progress" data-notify="progressbar">' +
'<div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
'</div>' +
'<a href="{3}" target="{4}" data-notify="url"></a>' +
'</div>'
});
};
</script>
I have tried replacing the hard coded phrase by the variable welcome
$.notify
? I see that the official website mentions this:$.notify( string|object, [ options ])
as a way of initializing, but using{icon:icon, title: title, message:message}
doesn't seem to be working. You can pass the a string as your message (first argument) and anoptions
object (second argument), and it will work.