mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-06 05:04:35 +08:00
JS code improvement [SCI-442]
This commit is contained in:
parent
246dae4f46
commit
868ffd03d6
2 changed files with 5 additions and 3 deletions
|
@ -1,9 +1,9 @@
|
|||
$(document.body).ready(function () {
|
||||
$('.btn-more-notifications')
|
||||
.on("ajax:success", function (e, data) {
|
||||
var list = $('.notifications-list');
|
||||
var moreBtn = $('.btn-more-notifications');
|
||||
if (data.html) {
|
||||
var list = $('.notifications-list');
|
||||
var moreBtn = $('.btn-more-notifications');
|
||||
// Remove button if all notifications are shown
|
||||
if (data.results_number < data.per_page) {
|
||||
moreBtn.remove();
|
||||
|
@ -12,6 +12,8 @@ $(document.body).ready(function () {
|
|||
moreBtn.attr('href', data.more_notifications_url);
|
||||
}
|
||||
$(list).append(data.html);
|
||||
} else if (data.results_number < 1) {
|
||||
moreBtn.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ class UserNotificationsController < ApplicationController
|
|||
|
||||
def index
|
||||
@last_notification_id = params[:from].to_i || 0
|
||||
@per_page = 5
|
||||
@per_page = 10
|
||||
|
||||
@notifications =
|
||||
UserNotification.last_notifications(@current_user,
|
||||
|
|
Loading…
Add table
Reference in a new issue