added support for widget redrawing. popcorn-port
authorhamidouk
Mon, 09 Jan 2012 15:38:54 +0100
branchpopcorn-port
changeset 599 a5a5e70d46a7
parent 598 50cfc3600365
child 600 4e669328ab6d
added support for widget redrawing.
src/js/widgets/annotationsListWidget.js
--- a/src/js/widgets/annotationsListWidget.js	Mon Jan 09 15:38:31 2012 +0100
+++ b/src/js/widgets/annotationsListWidget.js	Mon Jan 09 15:38:54 2012 +0100
@@ -11,7 +11,8 @@
 IriSP.AnnotationsListWidget.prototype.clearWidget = function() {
 };
 
-IriSP.AnnotationsListWidget.prototype.draw = function() {
+/** draw the annotation list */
+IriSP.AnnotationsListWidget.prototype.drawList = function() {
   var _this = this;
 
   var view_type = this._serializer.getContributions();
@@ -45,5 +46,15 @@
   }
 
   var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list});
-  this.selector.append(widgetMarkup);
+  this.selector.html(widgetMarkup);
+};
+
+IriSP.AnnotationsListWidget.prototype.draw = function() {
+
+  this.drawList();
+  this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", IriSP.wrap(this, this.redraw));
+};
+
+IriSP.AnnotationsListWidget.prototype.redraw = function() {
+  this.drawList();
 };
\ No newline at end of file