From 94a3e2c7a4bc63de6bc8afcf6da29cd106002099 Mon Sep 17 00:00:00 2001 From: Zev Benjamin Date: Thu, 7 Mar 2013 14:12:27 -0500 Subject: [PATCH] Use a delegated event handler on the presence list This code also has the side effect of making it no longer possible to click to the right of a name to start composing a message to them. Fixes #931 (imported from commit 80e995ccc8ead18b80a39181c47cc94d6063f0f6) --- zephyr/static/js/ui.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index 1025f067e1..8dadccb684 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -895,6 +895,12 @@ $(function () { var message = current_msg_list.get(rows.id(row)); timerender.set_full_datetime(message, time_elem); }); + + $('#user_presences').on('click', 'a', function (e) { + var email = $(e.target).attr('data-email'); + compose.start('private', {private_message_recipient: email}); + e.preventDefault(); + }); }); function sort_narrow_list() { @@ -994,14 +1000,10 @@ exports.set_presence_list = function (users, presence_info) { function add_entry(name, email, type) { var entry = $('
  • ') - .append($('').attr('href', '#') + .append($('').attr({href: '#', 'data-email': email}) .text(name)) .addClass('user_' + type) - .attr('title', name + presence_descriptions[type]) - .click(function (e) { - compose.start('private', {private_message_recipient: email}); - e.preventDefault(); - }); + .attr('title', name + presence_descriptions[type]); $('#user_presences').append(entry); }