From fd4259edef1faa91035a82db79ddf978f7db0e1c Mon Sep 17 00:00:00 2001 From: Arvind Date: Mon, 15 Sep 2014 15:26:44 +0530 Subject: [PATCH] Fixing annotation remaining editable after swt'ing. --- swtr/static/js/img_swtr.js | 5 +++-- swtr/static/js/main.js | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/swtr/static/js/img_swtr.js b/swtr/static/js/img_swtr.js index a8764bb..5c9ded6 100644 --- a/swtr/static/js/img_swtr.js +++ b/swtr/static/js/img_swtr.js @@ -114,7 +114,7 @@ initialize: function(options) { this.$el = $('#img-annotation-wrapper'); this.listenTo(this.collection, 'add', this.render); - this.listenTo(this.collection, 'change', this.render); + // this.listenTo(this.collection, 'change', this.render); var self = this; // attach event handlers to the anno object @@ -170,7 +170,8 @@ this.collection.each(this.render, this); }, showSwtHelp: function(annotation) { - var self = swtr.imgAnnoView;//TODO: figure out how we can bind the scope when this func is called as a callback + var self = swtr.imgAnnoView; + //TODO: figure out how we can bind the scope when this func is called as a callback self.helpview.step(3); $('#sweet').show(); }, diff --git a/swtr/static/js/main.js b/swtr/static/js/main.js index 2e223cd..9bcceb1 100644 --- a/swtr/static/js/main.js +++ b/swtr/static/js/main.js @@ -51,7 +51,7 @@ }, render: function() { console.log('sweetsview rendering'); - debugger; +// debugger; $('#sweet-list').html('

These are your sweet annotations!

'); _.each(this.collection.models, function(swt) { if(swt.has('id')) { @@ -95,7 +95,7 @@ postSweets: function(event) { event.preventDefault(); console.log('posting swts'); - debugger; +// debugger; var appView = swtr.appView; var self = this; this.helpview.step(5); @@ -104,6 +104,12 @@ this.collection.post({ success: function(collection, response) { console.log('updated', collection, response); + anno.reset(); + anno.makeAnnotatable($("#annotatable-img")[0]); + swtr.imgAnnoView.renderWith(); + // _.each(collection, function(k) { + // anno.removeAnnotation(k['how']); + // }); swtr.sweets.add(collection, {merge: true}); console.log('new swtr coll', swtr.sweets); appView.$overlay.hide(); @@ -223,11 +229,11 @@ sweet: function(event) { event.preventDefault(); console.log('sweeting'); - debugger; +// debugger; this.getSweets(); - debugger; +// debugger; this.showSweets(); - debugger; +// debugger; return false; }, // function to update the urls in the UI if an image is loaded internally @@ -334,7 +340,7 @@ destroy: function() { this.helpview.remove(); this.remove(); - }, + } }); var OCDView = Backbone.View.extend({ -- 1.7.10.4