Avoid using inline javascript to update message list
This commit is contained in:
parent
ed1f441ef3
commit
4a6779abf7
9 changed files with 44 additions and 14 deletions
30
app/assets/javascripts/messages.js
Normal file
30
app/assets/javascripts/messages.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
$(document).ready(function () {
|
||||
$(".inbox-mark-unread").on("ajax:success", function (event, data) {
|
||||
$("#inboxanchor").remove();
|
||||
$(".user-button").before(data.inboxanchor);
|
||||
|
||||
$("#inbox-count").replaceWith(data.inbox_count);
|
||||
|
||||
$(this).parents(".inbox-row").removeClass("inbox-row").addClass("inbox-row-unread");
|
||||
});
|
||||
|
||||
$(".inbox-mark-read").on("ajax:success", function (event, data) {
|
||||
$("#inboxanchor").remove();
|
||||
$(".user-button").before(data.inboxanchor);
|
||||
|
||||
$("#inbox-count").replaceWith(data.inbox_count);
|
||||
|
||||
$(this).parents(".inbox-row-unread").removeClass("inbox-row-unread").addClass("inbox-row");
|
||||
});
|
||||
|
||||
$(".inbox-destroy").on("ajax:success", function (event, data) {
|
||||
$("#inboxanchor").remove();
|
||||
$(".user-button").before(data.inboxanchor);
|
||||
|
||||
$("#inbox-count").replaceWith(data.inbox_count);
|
||||
|
||||
$(this).parents(".inbox-row, .inbox-row-unread").fadeOut(800, "linear", function () {
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue