소스 검색

Merge pull request #2505 from bmaranville/plotly_event_handler_fix

Register plotly event handlers only once, at mount
Falko Schindler 1 년 전
부모
커밋
02376e9230
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      nicegui/elements/plotly.vue

+ 5 - 3
nicegui/elements/plotly.vue

@@ -23,8 +23,13 @@ export default {
         Plotly.react(this.$el.id, this.options.data, this.options.layout);
       } else {
         Plotly.newPlot(this.$el.id, this.options.data, this.options.layout, options.config);
+        this.set_handlers();
       }
 
+      // store last options
+      this.last_options = options;
+    },
+    set_handlers() {
       // forward events
       for (const name of [
         // source: https://plotly.com/javascript/plotlyjs-events/
@@ -60,9 +65,6 @@ export default {
           this.$emit(name, args);
         });
       }
-
-      // store last options
-      this.last_options = options;
     },
   },
   data() {