Fixed button widget click event handler/

pull/37/head
Jonathan Frederic 13 years ago
parent b5d4eda19b
commit d72262e071

@ -12,7 +12,8 @@ require(["notebook/js/widget"], function(){
this.$el = $("<button />")
.addClass('btn')
.click(function() {
that.model.set('clicks', that.model.get('clicks') + 1)
that.model.set('clicks', that.model.get('clicks') + 1);
that.model.apply(that);
});
this.update(); // Set defaults.

@ -1,3 +1,6 @@
import inspect
import types
from base import Widget
from IPython.utils.traitlets import Unicode, Bool, Int
@ -12,12 +15,14 @@ class ButtonWidget(Widget):
_click_handlers = []
def handle_click(self, callback, remove=False):
def on_click(self, callback, remove=False):
if remove:
self._click_handlers.remove(callback)
else:
self._click_handlers.append(callback)
def _clicks_changed(self, name, old, new):
if new > old:
for handler in self._click_handlers:

Loading…
Cancel
Save