首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从JSON创建表单,如何添加关闭按钮?

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

Stack Overflow用户
提问于 2013-12-04 06:53:12
回答 1查看 1.1K关注 0票数 0

使用这个https://github.com/joshfire/jsonform,我创建了表单。

代码语言:javascript
复制
$('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>');
      }
    }
}); 

在这种情况下,默认情况下存在提交按钮。

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

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-04 07:27:51

代码语言:javascript
复制
$('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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20368945

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档