簡単な通知システムを書いていますが、JS / jQuery(フロントエンドは私にとっては新しい)を学んでいるだけで、問題があります。私は次のコードを書きました:
(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);
しかし、メソッドにエラーがありますnotification.hide
:this.element
isundefined。エラーが発生した場所を説明していただけますか?ありがとうございました。