|
This page illustrates the very simple implementation of jQuery Notice How it worksThis plugin extends jQuery. That means that you can call it like this: jQuery.noticeAdd() or jQuery.noticeRemove(). The fact that it is not bound to an html object makes this plugin very easy to use. It is callable or removable from any function. For example: it could be initiated as callback from a function or on a success or failure after an Ajax request. The html<button class="add">Add sticky notice</button>
<button class="add2">Add normal notice</button>
<button class="remove">Revome all notices</button> The javascript$(document).ready(function()
{
$('button.add').click(function()
{
jQuery.noticeAdd({
text: 'This is a notification that you have to remove',
stay: true
});
});
$('button.add2').click(function()
{
jQuery.noticeAdd({
text: 'This is a notification that does not stay',
stay: false
});
});
$('button.remove').click(function()
{
jQuery.noticeRemove($('.notice-item-wrapper'), 400);
});
});These are the defaults settings for the noticeAdd function var defaults = {
inEffect: {opacity: 'show'}, // in effect
inEffectDuration: 600, // in effect duration in miliseconds
stayTime: 3000, // time in miliseconds before the item has to disappear
text: '', // content of the item
stay: false, // should the notice item stay or not?
type: 'notice' // could also be error, succes
}You can overwrite these defaults like this: jQuery.noticeAdd({
text: 'This is a notification that you have to remove',
stay: true
});
|
simple and elegant.. :o) like it
Thanks! I hope it works for you.
This is awesome. I like it far better than jGrowl. Question: I tried setting type to 'error' and 'success' and it didn't seem to change the look of the notice. Am I doing something wrong?
Hi, Thanks for the great reply. If you change the type setting a class gets added to the notification item. Just add a css class like: .notice, .error or .success and off you go.
You da man! Thanks. Any thoughts. on how I could keep the notices in the upper right side, but have the errors and success come up in the middle of the screen?
Thanks again... love this plug-in/extension :-)
This is exactly what I was looking for. Thanks for your precious time.
Hey ilruffo, thanks for you great comment. I spend the time enjoying the build!
I tried two other plugins but found them not meeting my criteria of small and easy to implement. This one is brilliant... thanks and I appreciate your time and effort!
I may be using this incorrectly but if I issue a jQuery.noticeRemove (to remove any sticky notices) then issue jQuery.noticeAdd, my new notice is also removed.
Hi mamboen,
You can give an jQuery object to the remove notice function. Can you maybe show me your code? I cannot see why you last (new) notice gets removed.
Tim, here's the code, I've removed the unecessary code.
function getData2() { // First, drop any "notices" that might be currently raised. jQuery.noticeRemove($('.notice-item-wrapper')); var inputContents = $('#part_number').val() + $('#customer').val() + $('#date_code').val() + $('#lot_number').val(); if ($.trim(inputContents) == '') { // Raise notice to alert user. jQuery.noticeAdd({ text: 'Please enter query parameter(s).', stay: true, type: 'error' }); } }You can also duplicate it on your demo page... 1) click Add sticky notice 2) click Remove all notices, then quickly 3) click Add normal notice.
hth!
I'm experiencing the same thing as mamboen; I'll file an issue for it.
Awesome! I've found a perfect situation where I can use this. :D
Just one question… Is it possible to add a sound to the notification?
Hi. maybe the problem can be the time effect of removeNotice... I set 600 and 300 to 0 and now there isn't the problem.
I solve editing noticeRemove
noticeRemove: function(obj) { obj.animate({opacity: '0'}, 600, function() { obj.parent().animate({height: '0px'}, 300, function() { $(obj).find('.notice-item').remove(); }); }); }Is it possible to place the notice box somewhere else besides on the upper right hand corner?
Suppose i append <div class="notice_text">The text</div> on the notice more than once and insert a code e.g $('.notice_text').click(function(){ alert('Alerted'); }); it would alert only with the first div that i had appended, and the other div(s) seems to have no function at all , is there any way to fix this where the function could be applied to ever div(s) that i had appended??? Trying to create a download package with this script and i am facing this problem to remove the div(s) and call ajax function.
cool man... it can be my next feature on my webpage....
@haryx8, sound great! Post the link here when you write about the plugin! :-)