使用语义UI:对checkChecked函数使用ajax响应

时间:2018-06-18 07:04:57

标签: checkbox semantic-ui

我希望复选框在每次检查和取消选中时发布,但在更改之前验证它是否成功或失败。语义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
                }
            )
        }
    });

0 个答案:

没有答案