Browse Source

Update mcInitializer

Vijayakrishnan 4 years ago
parent
commit
f4317d14d6
2 changed files with 15 additions and 14 deletions
  1. 4 3
      public/js/mc-init.js
  2. 11 11
      resources/views/app/patient/note/section_script.blade.php

+ 4 - 3
public/js/mc-init.js

@@ -1,8 +1,9 @@
 window.mcInitializers = {};
 window.mcInitializers = {};
 window.addMCInitializer = function(_name, _func, _container) {
 window.addMCInitializer = function(_name, _func, _container) {
-    // if(!!window.mcInitializers[_name]) {
-    //     console.warn('ALIX initializer ' + _name + ' exists. Will overwrite.');
-    // }
+    if(!!window.mcInitializers[_name]) {
+        // console.warn('ALIX initializer ' + _name + ' exists. Will overwrite.');
+        delete window.mcInitializers[_name];
+    }
     window.mcInitializers[_name] = {
     window.mcInitializers[_name] = {
         func: _func,
         func: _func,
         container: _container
         container: _container

+ 11 - 11
resources/views/app/patient/note/section_script.blade.php

@@ -132,17 +132,17 @@
 
 
         function initChangeListener(_elem) {
         function initChangeListener(_elem) {
             new MutationObserver(debounce(function() {
             new MutationObserver(debounce(function() {
-                    if(_elem.closest('.note-section').is('.edit')) {
-                        // console.log('ALIX: In edit mode. Auto-saving', _elem.closest('.note-section').attr('data-section-template-name'))
-                        doSave(_elem.closest('.note-section'))
-                    }
-                    else {
-                        // console.log('ALIX: Not in edit mode. Not auto-saving', _elem.closest('.note-section').attr('data-section-template-name'))
-                    }
-                }, 250))
-                .observe(_elem[0], {
-                    attributes: true
-                });
+                if(_elem.closest('.note-section').is('.edit')) {
+                    // console.log('ALIX: In edit mode. Auto-saving', _elem.closest('.note-section').attr('data-section-template-name'))
+                    doSave(_elem.closest('.note-section'))
+                }
+                else {
+                    // console.log('ALIX: Not in edit mode. Not auto-saving', _elem.closest('.note-section').attr('data-section-template-name'))
+                }
+            }, 250))
+            .observe(_elem[0], {
+                attributes: true
+            });
         }
         }
 
 
         addMCInitializer('note-sections-list', init);
         addMCInitializer('note-sections-list', init);