Show More
@@ -12,7 +12,8 require(["notebook/js/widget"], function(){ | |||||
12 | this.$el = $("<button />") |
|
12 | this.$el = $("<button />") | |
13 | .addClass('btn') |
|
13 | .addClass('btn') | |
14 | .click(function() { |
|
14 | .click(function() { | |
15 | that.model.set('clicks', that.model.get('clicks') + 1) |
|
15 | that.model.set('clicks', that.model.get('clicks') + 1); | |
|
16 | that.model.apply(that); | |||
16 | }); |
|
17 | }); | |
17 |
|
18 | |||
18 | this.update(); // Set defaults. |
|
19 | this.update(); // Set defaults. |
@@ -1,3 +1,6 | |||||
|
1 | import inspect | |||
|
2 | import types | |||
|
3 | ||||
1 | from base import Widget |
|
4 | from base import Widget | |
2 | from IPython.utils.traitlets import Unicode, Bool, Int |
|
5 | from IPython.utils.traitlets import Unicode, Bool, Int | |
3 |
|
6 | |||
@@ -12,12 +15,14 class ButtonWidget(Widget): | |||||
12 |
|
15 | |||
13 | _click_handlers = [] |
|
16 | _click_handlers = [] | |
14 |
|
17 | |||
15 | def handle_click(self, callback, remove=False): |
|
18 | ||
|
19 | def on_click(self, callback, remove=False): | |||
16 | if remove: |
|
20 | if remove: | |
17 | self._click_handlers.remove(callback) |
|
21 | self._click_handlers.remove(callback) | |
18 | else: |
|
22 | else: | |
19 | self._click_handlers.append(callback) |
|
23 | self._click_handlers.append(callback) | |
20 |
|
24 | |||
|
25 | ||||
21 | def _clicks_changed(self, name, old, new): |
|
26 | def _clicks_changed(self, name, old, new): | |
22 | if new > old: |
|
27 | if new > old: | |
23 | for handler in self._click_handlers: |
|
28 | for handler in self._click_handlers: |
General Comments 0
You need to be logged in to leave comments.
Login now