summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/notes.js9
-rw-r--r--app/controllers/projects/notes_controller.rb15
-rw-r--r--app/views/projects/notes/index.js.haml4
3 files changed, 20 insertions, 8 deletions
diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js
index defbf81f580..e39bfc0f792 100644
--- a/app/assets/javascripts/notes.js
+++ b/app/assets/javascripts/notes.js
@@ -6,7 +6,7 @@ var NoteList = {
target_type: null,
init: function(tid, tt, path) {
- NoteList.notes_path = path + ".js";
+ NoteList.notes_path = path + ".json";
NoteList.target_id = tid;
NoteList.target_type = tt;
NoteList.target_params = "target_type=" + NoteList.target_type + "&target_id=" + NoteList.target_id;
@@ -411,7 +411,10 @@ var NoteList = {
data: NoteList.target_params,
complete: function(){ $('.js-notes-busy').removeClass("loading")},
beforeSend: function() { $('.js-notes-busy').addClass("loading") },
- dataType: "script"
+ success: function(data) {
+ NoteList.setContent(data.html);
+ },
+ dataType: "json"
});
},
@@ -419,7 +422,7 @@ var NoteList = {
* Called in response to getContent().
* Replaces the content of #notes-list with the given html.
*/
- setContent: function(newNoteIds, html) {
+ setContent: function(html) {
$("#notes-list").html(html);
},
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb
index 8214163c315..dc479a9c755 100644
--- a/app/controllers/projects/notes_controller.rb
+++ b/app/controllers/projects/notes_controller.rb
@@ -14,7 +14,20 @@ class Projects::NotesController < Projects::ApplicationController
@discussions = discussions_from_notes
end
- respond_with(@notes)
+ respond_to do |format|
+ format.html { redirect_to :back }
+ format.json do
+ html = render_to_string(
+ "projects/notes/_notes",
+ layout: false,
+ formats: [:html]
+ )
+
+ render json: {
+ html: html,
+ }
+ end
+ end
end
def create
diff --git a/app/views/projects/notes/index.js.haml b/app/views/projects/notes/index.js.haml
deleted file mode 100644
index 6c4ed203497..00000000000
--- a/app/views/projects/notes/index.js.haml
+++ /dev/null
@@ -1,4 +0,0 @@
-- unless @notes.blank?
- var notesHtml = "#{escape_javascript(render 'projects/notes/notes')}";
- - new_note_ids = @notes.map(&:id)
- NoteList.setContent(#{new_note_ids}, notesHtml);