commit
This commit is contained in:
45
assets/js/admin.js
Normal file
45
assets/js/admin.js
Normal file
@@ -0,0 +1,45 @@
|
||||
jQuery(document).ready(function($) {
|
||||
// 使链接可排序
|
||||
$('#flm-sortable-links').sortable({
|
||||
handle: '.flm-link-preview',
|
||||
placeholder: 'flm-link-item-placeholder',
|
||||
axis: 'y',
|
||||
update: function() {
|
||||
// 更新排序后可以在这里添加AJAX保存逻辑
|
||||
}
|
||||
});
|
||||
|
||||
// 删除链接
|
||||
$('.flm-delete-link').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!confirm('确定要删除这个链接吗?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $button = $(this);
|
||||
var linkId = $button.data('link-id');
|
||||
|
||||
$.ajax({
|
||||
url: flm_vars.ajax_url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'flm_delete_link',
|
||||
link_id: linkId,
|
||||
nonce: flm_vars.nonce
|
||||
},
|
||||
beforeSend: function() {
|
||||
$button.prop('disabled', true).text('删除中...');
|
||||
},
|
||||
success: function() {
|
||||
$button.closest('.flm-link-item').fadeOut(300, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
alert('删除失败,请重试');
|
||||
$button.prop('disabled', false).text('删除');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user