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

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

本文关键字:添加 关闭按钮 何添加 模式 JSON 创建 表单      更新时间:2024-02-17

有了这个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