From 6fbf2f9720ae153021e92e94fc1ff60eb1b0bc36 Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Fri, 12 Oct 2012 04:22:27 -0700 Subject: [PATCH] revert toString changes; use attr('data-id') instead of data('id') when mongo ids are involved --- .../views/discussion_thread_list_view.coffee | 6 +++++- lms/templates/discussion/_underscore_templates.html | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee b/lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee index e97ca364da..c5f66c87ec 100644 --- a/lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee +++ b/lms/static/coffee/src/discussion/views/discussion_thread_list_view.coffee @@ -156,7 +156,11 @@ if Backbone? @$(".post-list").append(view.el) threadSelected: (e) => - thread_id = $(e.target).closest("a").data("id") + # Use .attr('data-id') rather than .data('id') because .data does type + # coercion. Usually, this is fine, but when Mongo gives an object id with + # no letters, it casts it to a Number. + + thread_id = $(e.target).closest("a").attr("data-id") @setActiveThread(thread_id) @trigger("thread:selected", thread_id) # This triggers a callback in the DiscussionRouter which calls the line above... false diff --git a/lms/templates/discussion/_underscore_templates.html b/lms/templates/discussion/_underscore_templates.html index d1d3f6db56..0a691ac36f 100644 --- a/lms/templates/discussion/_underscore_templates.html +++ b/lms/templates/discussion/_underscore_templates.html @@ -1,5 +1,5 @@