簡體   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