##// END OF EJS Templates
Added `method` property to messages from the front-end
Jonathan Frederic -
Show More
@@ -78,7 +78,7 b' define(["components/underscore/underscore-min",'
78 }
78 }
79 }
79 }
80 var callbacks = this._make_callbacks(cell);
80 var callbacks = this._make_callbacks(cell);
81 var data = {'custom_content': content};
81 var data = {method: 'custom', custom_content: content};
82 this.comm.send(data, callbacks);
82 this.comm.send(data, callbacks);
83 },
83 },
84
84
@@ -156,7 +156,7 b' define(["components/underscore/underscore-min",'
156 if (selector === undefined) {
156 if (selector === undefined) {
157 selector = '';
157 selector = '';
158 }
158 }
159
159
160 var class_list = msg.content.data.class_list;
160 var class_list = msg.content.data.class_list;
161 this._execute_views_method(method, selector, class_list);
161 this._execute_views_method(method, selector, class_list);
162 break;
162 break;
@@ -253,7 +253,7 b' define(["components/underscore/underscore-min",'
253 }
253 }
254 }
254 }
255
255
256 var data = {sync_method: method, sync_data: send_json};
256 var data = {method: 'backbone', sync_method: method, sync_data: send_json};
257
257
258 var cell = null;
258 var cell = null;
259 if (this.last_modified_view != undefined && this.last_modified_view != null) {
259 if (this.last_modified_view != undefined && this.last_modified_view != null) {
@@ -113,16 +113,19 b' class Widget(LoggingConfigurable):'
113 def _handle_msg(self, msg):
113 def _handle_msg(self, msg):
114 """Called when a msg is recieved from the frontend"""
114 """Called when a msg is recieved from the frontend"""
115 data = msg['content']['data']
115 data = msg['content']['data']
116
116 method = data['method']
117
117 # Handle backbone sync methods CREATE, PATCH, and UPDATE
118 # Handle backbone sync methods CREATE, PATCH, and UPDATE
118 if 'sync_method' in data and 'sync_data' in data:
119 if method == 'backbone':
119 sync_method = data['sync_method']
120 if 'sync_method' in data and 'sync_data' in data:
120 sync_data = data['sync_data']
121 sync_method = data['sync_method']
121 self._handle_recieve_state(sync_data) # handles all methods
122 sync_data = data['sync_data']
123 self._handle_recieve_state(sync_data) # handles all methods
122
124
123 # Handle a custom msg from the front-end
125 # Handle a custom msg from the front-end
124 if 'custom_content' in data:
126 elif method == 'custom':
125 self._handle_custom_msg(data['custom_content'])
127 if 'custom_content' in data:
128 self._handle_custom_msg(data['custom_content'])
126
129
127
130
128 def _handle_custom_msg(self, content):
131 def _handle_custom_msg(self, content):
General Comments 0
You need to be logged in to leave comments. Login now