mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-19 22:11:45 +08:00
17 lines
505 B
JavaScript
17 lines
505 B
JavaScript
|
|
$(document).on('click', '.asset .change-preview-type', function(e) {
|
|
var viewMode = $(this).data('preview-type');
|
|
var toggleUrl = $(this).data('toggle-view-url');
|
|
var assetId = $(this).closest('.asset').data('asset-id');
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
$.ajax({
|
|
url: toggleUrl,
|
|
type: 'PATCH',
|
|
dataType: 'json',
|
|
data: { asset: { view_mode: viewMode } },
|
|
success: function(data) {
|
|
$(`.asset[data-asset-id=${assetId}]`).replaceWith(data.html);
|
|
}
|
|
});
|
|
});
|