Avoid loading annotations twice when creating new one
This commit is contained in:
@@ -101,6 +101,7 @@ App.LegislationAnnotatable =
|
||||
$('#comments-box textarea').focus()
|
||||
|
||||
$("#new_legislation_annotation").on("ajax:complete", (e, data, status, xhr) ->
|
||||
App.LegislationAnnotatable.app.destroy()
|
||||
if data.status == 200
|
||||
App.LegislationAnnotatable.remove_highlight()
|
||||
$("#comments-box").html("").hide()
|
||||
@@ -152,7 +153,7 @@ App.LegislationAnnotatable =
|
||||
ann_id = $this.data("legislation-draft-version-id")
|
||||
base_url = $this.data("legislation-annotatable-base-url")
|
||||
|
||||
app = new annotator.App()
|
||||
App.LegislationAnnotatable.app = new annotator.App()
|
||||
.include ->
|
||||
beforeAnnotationCreated: (ann) ->
|
||||
ann["legislation_draft_version_id"] = ann_id
|
||||
@@ -166,9 +167,9 @@ App.LegislationAnnotatable =
|
||||
.include(App.LegislationAnnotatable.scrollToAnchor)
|
||||
.include(annotator.storage.http, { prefix: base_url, urls: { search: "/annotations/search" } })
|
||||
|
||||
app.start().then ->
|
||||
app.ident.identity = current_user_id
|
||||
App.LegislationAnnotatable.app.start().then ->
|
||||
App.LegislationAnnotatable.app.ident.identity = current_user_id
|
||||
|
||||
options = {}
|
||||
options["legislation_draft_version_id"] = ann_id
|
||||
app.annotations.load(options)
|
||||
App.LegislationAnnotatable.app.annotations.load(options)
|
||||
|
||||
Reference in New Issue
Block a user