--- a/swtr/static/js/app.js +++ b/swtr/static/js/app.js @@ -138,7 +138,9 @@ if(!(swtr.who)) { swtr.who = "Guest"; } - swtr.TxtAnnoSwts.add(new TxtAnnoSwt({how: annotation, + // Removing the highlights key value pair from annotation object. + var tempAnnotation = _.omit(annotation, 'highlights'); + swtr.TxtAnnoSwts.add(new TxtAnnoSwt({how: tempAnnotation, where: pageURL, who: swtr.who})); if($("#show-sweets").attr('disabled')) { @@ -189,13 +191,17 @@ this.loadOverlayBar(); }, loadOverlayBar: function() { - var template = ""; + var template = ""; $(document.body).append(template); }, @@ -206,6 +212,7 @@ showSweets: function(e) { $("#sweet-list-wrapper").show(); swtr.TxtAnnoSwts.each(function(model){ + console.log(model, model.isNew()); var templateStr ='
  • '+ '@<%= who %> #<%= what %> '+ '<%= where.substr(0, 30) + "..." %> '+ @@ -229,7 +236,9 @@ $("#sweet-list").html(''); }, postSweet: function(e) { - swtr.TxtAnnoSwts.post({success: function(data) { + swtr.TxtAnnoSwts.post({success: function(collection, data) { + swtr.TxtAnnoSwts.set(collection); + $("#sweet-list").html(''); alert("Your SWeets are posted!!"); }, error: function(data) { --- a/swtr/static/js/swtmaker.js +++ b/swtr/static/js/swtmaker.js @@ -197,7 +197,7 @@ this.collection.post({ success: function(collection, response) { console.log(collection, response); - swtr.sweets.update(collection); + swtr.sweets.set(collection); //TODO: move this to a annotation view or something anno.removeAll(); _.each(swtr.sweets.models, function(swt) { @@ -312,6 +312,9 @@ return false; } else { + if(!url) { + return false; + } window.location.href = '/annotate?where=' + url; } },