I'm writing a simple notifications system but I'm just learning JS / jQuery (front-end is new for me) and I have problem. I wrote following code:
(function ($) {
var notification = function(title, msg, duration) {
this.element = $('<div class="notification"><h3>' + title + '</h3><div class="notification_body">' + msg + '<br/><i>(для скрытия уведомления кликните здесь два раза)</i></div></div>');
this.element.dblclick(notification.hide);
$('#notifications_bar').prepend(this.element.hide().fadeIn(1000));
}
notification.hide = function() {
var $this = this;
this.element.fadeOut(1000, function () {
$this.element.remove();
})
}
$.extend({
notify: function(title, msg, duration) {
return new notification(title, msg, duration);
}
});
})
(jQuery);
But there is an error in method notification.hide: this.element is undefined.
Can you explain me where the error?
Thank you.