| 1 |
jQuery(document).ready(function ($) { |
| 2 |
$('#sort-replies').on('change', function (e) { |
| 3 |
e.preventDefault(); |
| 4 |
var sort = $(this).val(); |
| 5 |
var topic_id = $('section[role="main"]').attr('id') || forumax_localize_script.bbp_topic_id; |
| 6 |
|
| 7 |
var data = { |
| 8 |
action: 'sort_bbp_replies', |
| 9 |
sort: sort, |
| 10 |
topic_id: topic_id, |
| 11 |
nonce: forumax_localize_script.nonce |
| 12 |
}; |
| 13 |
console.log(data); |
| 14 |
$('#topic-' + topic_id + '-replies .reply-result').addClass('loading'); |
| 15 |
$.post(forumax_localize_script.ajaxurl, data, function (response) { |
| 16 |
if (response.success) { |
| 17 |
$('#topic-' + topic_id + '-replies .reply-result').html(response.data.html); |
| 18 |
// Re-initialize admin dropdowns after AJAX sort update. |
| 19 |
if ($.fn.frmxNiceSelect) { |
| 20 |
$('select.bbp-admin-dropdown-menu').each(function () { |
| 21 |
var $select = $(this); |
| 22 |
$select.nextAll('.nice-select, .frmx-nice-select').remove(); |
| 23 |
$select.frmxNiceSelect(); |
| 24 |
$select.next('.frmx-nice-select').removeClass('nice-select'); |
| 25 |
}); |
| 26 |
} |
| 27 |
if (typeof window.frmxEnhanceAdminDropdowns === 'function') { |
| 28 |
window.frmxEnhanceAdminDropdowns(); |
| 29 |
} |
| 30 |
} |
| 31 |
$('#topic-' + topic_id + '-replies .reply-result').removeClass('loading'); |
| 32 |
}); |
| 33 |
}); |
| 34 |
}); |