javascript override class variable

643 views Asked by At

I have class with variables, I want change variable value by another function in external file

Class code

frappe.ui.Notifications = class Notifications {
    constructor() {
        frappe.model
            .with_doc('Notification Settings', frappe.session.user)
            .then(doc => {
                this.notifications_settings = doc;
                this.make();
            });
    }

    make() {
        this.$dropdown = $('.navbar').find('.dropdown-notifications');
        this.$dropdown_list = this.$dropdown.find('.notifications-list');
        this.$notification_indicator = this.$dropdown.find('.notifications-indicator');
    }
};

i wand change variable this.$dropdown

frappe.ui.Notifications.$dropdown =  $('.Header').find('.dropdown-item-notifications');
1

There are 1 answers

0
Faris Ansari On BEST ANSWER

The Notification class instance is set at frappe.frappe_toolbar.notifications. You can use it to override the property.

frappe.frappe_toolbar.notifications.$dropdown = $('.Header').find('.dropdown-item-notifications');