UIkit的confirm,好看點

一,官方推薦的樣碼。ajax

 <button type="button" class="uk-button" onclick="UIkit.modal.prompt('Name:', '', function(val){ UIkit.modal.alert('Hello '+(val || 'Mr noname')+'!'); });">Prompt</button>

<pre><code>UIkit.modal.prompt("Name:", value, function(newvalue){
    // 點擊OK提交後執行
});</code></pre>

 

二,我實現的樣碼json

var statu = UIkit.modal.confirm("將發佈單" + deploy_version + "從" + org_type + "部署到" + env_type + "環境。是否確認?" ,function() {
            promiseJenkins = $.ajax({
                url:'/valid/env_valid/',
                type: 'post',
                data:{
                    deploy_version: deploy_version,
                    env_type: env_type,
                    org_type: org_type,
                },
                dataType: 'json',
                beforeSend: function(){
                    $(_self).attr('disabled',"true");
                    $(_self).append(" <i class='uk-icon-cog uk-icon-spin'></i>");

                },
                error: function(){
                    alert('500 Error.');
                },
                success: function(json){
                    $(_self).children('i').remove();
                    $(_self).append(" <i class='uk-icon-check'></i>")
                    window.location.reload();
                    console.log(json);
                    UIkit.notify(json.return,  {timeout: 0});
                }
            });
        });

三,LOOK:promise

相關文章
相關標籤/搜索