From 6b9b9d2d1c27600969388ad10d749bb6febc92b6 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 3 Jun 2017 17:51:20 -0400 Subject: Add autocomplete dropdown on comment subject and email fields --- assets/js/components/autocomplete-email.js | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'assets/js/components') diff --git a/assets/js/components/autocomplete-email.js b/assets/js/components/autocomplete-email.js index 1babd516..4a12a2fe 100644 --- a/assets/js/components/autocomplete-email.js +++ b/assets/js/components/autocomplete-email.js @@ -1,25 +1,21 @@ KB.onClick('.js-autocomplete-email', function (e) { var email = KB.dom(e.target).data('email'); + var emailField = KB.find('.js-mail-form input[type="email"]'); - if (email) { - var emailField = KB.find('.js-task-mail-form input[type="email"]'); - - if (emailField) { - emailField.attr('value', email); - _KB.controllers['Dropdown'].close(); - } + if (email && emailField) { + emailField.build().value = email; } + + _KB.controllers['Dropdown'].close(); }); KB.onClick('.js-autocomplete-subject', function (e) { var subject = KB.dom(e.target).data('subject'); + var subjectField = KB.find('.js-mail-form input[name="subject"]'); - if (subject) { - var subjectField = KB.find('.js-task-mail-form input[name="subject"]'); - - if (subjectField) { - subjectField.attr('value', subject); - _KB.controllers['Dropdown'].close(); - } + if (subject && subjectField) { + subjectField.build().value = subject; } + + _KB.controllers['Dropdown'].close(); }); -- cgit v1.2.3