对话框 Dialog

默认
删除
$p.dialog("#btn_remove", {
    title: "提示",
    body: "你确定要删除吗?",
    submit: function(modal, data, params, callback) {
        modal.hide();
        $p.alert("你点击了确定");
    }
});
表单
添加
$p.dialog("#btn_add", {
    title: "添加用户",
    body: $("#tpl_user").html(),
    validate: function(modal, data, params) {
        return true;
    },
    submit: function(modal, data, params, callback) {
        modal.hide();
        $p.alert("你点击了确定");
    }
});
表单填充
编辑
$p.dialog("#btn_update", {
    title: "编辑用户",
    body: $("#tpl_user").html(),
    initForm: function(modal, form, params) {
        //获取用户信息
        model.getUser(params.id, params, function(data) {
            $p.form(form).val(data);
        });
    },
    validate: function(modal, data, params) {
        return true;
    },
    submit: function(modal, data, params, callback) {
        //更新用户信息
        model.update(params.id, data, function(resp,valid) {
            if(valid){
                $p.alert(resp.message);
                modal.hide();
            }
            modal.complete();
        });
    }
});
其他