繁体   English   中英

从JSON模式创建表单,如何添加关闭按钮?

[英]Created forms from JSON Schema, How to add Close button?

有了这个https://github.com/joshfire/jsonform,我创建了Form。

$('form').jsonForm({
    schema: {
        name: {type: 'string', title: 'Name', required: true},
        //age: {type: 'number', title: 'Age', required: true},
        comment: {type: 'textarea', title: 'Comments', required: true},             
        choice: {type: 'string',title: 'Title', 'enum': ['choice-1','choice-2','choice-3']},

    },          
    onSubmit: function (errors, values) {
      if (errors) {
        $('#res').html('<p>I beg your pardon?</p>');
      }
      else {
        $('#res').html('<p>Hello ' + values.name + '.' +
          (values.comment ? '<br/>You are ' + values.comment + '.' : '') +
          '</p>');
      }
    }
}); 

在默认情况下,存在“提交”按钮。

但是我想添加“关闭”按钮。

或如何删除或隐藏默认的“提交”按钮,以便添加其他“提交和关闭”按钮?

$('form').jsonForm({
    ...code
}); 
// Save reference to parent element to append custom buttons
var btn-container = $('form input[type=submit]').parent();

// Remove default 'submit' button
$('form input[type=submit]').remove();

// now add custom buttons in btn-container

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM