我希望复选框在每次检查和取消选中时发布,但在更改之前验证它是否成功或失败。语义UI具有可以返回false以防止更改的beforeCheck函数,但是这样写它不起作用,有没有办法从ajax返回false以使其工作?
$('.ui.checkbox').checkbox({
beforeChecked: function(){
let chapterInfo = {
isHidden: false
}
return $.post("editnovel", {
novel: chapterInfo
}).done(function( data ){
return true
}).fail(function( data){
return false
})
},
beforeUnchecked: function(){
let chapterInfo = {
isHidden: true
}
return $.post("editnovel", {
novel: chapterInfo
}).done(function( data ){
return true
}).fail(function( data){
return false
}
)
}
});