单击提交按钮时,提交表单 [英] Getting the form to submit when clicking the submit button

查看:201
本文介绍了单击提交按钮时,提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击按钮时,我想提交表单,但是它并不像我想象的那样简单,我总是最终得到一个 fp.getForm 不是一个函数,尽管提交处理程序直接从ExtJs文档获取,任何线索?

I'm trying to submit the form when the button is clicked, however it wasn't as simple as i thought, i always end up getting a fp.getForm is not a function, although the submit handler is taken directly from the ExtJs doc, any clue?

Players.panel.Subscription = function(config) {
    config = config || {};
    Ext.apply(config,{
        border: false
        ,baseCls: 'modx-formpanel'
        ,process: 'mgr/player/getSubscribers'
        ,standardSubmit: true
        ,url: Players.config.connectorUrl
        ,baseParams: { action: 'mgr/player/getSubscribers' }
        ,buttons: [{
                    text: 'Export er'
                    ,formBind: true
                    ,type: 'submit'
                    ,handler: function(){


                            var fp = this.ownerCt.ownerCt,
                                form = fp.getForm();
                            if (form.isValid()) {
                                // check if there are baseParams and if
                                // hiddent items have been added already
                                if (fp.baseParams && !fp.paramsAdded) {
                                    // add hidden items for all baseParams
                                    for (i in fp.baseParams) {
                                        fp.add({
                                            xtype: 'hidden',
                                            name: i,
                                            value: fp.baseParams[i]
                                        });
                                    }
                                    fp.doLayout();
                                    // set a custom flag to prevent re-adding
                                    fp.paramsAdded = true;
                                }
                                form.submit();
                            }

                }
                }]

    });
    Players.panel.Subscription.superclass.constructor.call(this,config);

};

我也尝试将基类从 modx-formpanel 替换为 formpanel basicform 没有成功。

I also tried replacing the base class from modx-formpanel to formpanel and basicform with no success.

谢谢

推荐答案

这是因为您没有表单面板。尝试这样:

It's because you have not a form panel. Try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="./ext/resources/css/ext-all.css" />
<script type="text/javascript" src="./ext/bootstrap.js"></script>
</head>
<body>
<script>
Ext.ns('Players.panel');
Ext.onReady(function() {  
  Players.panel.Subscription = Ext.extend(Ext.form.Panel, {
    constructor : function(config) {
      config = Ext.apply({
          border: false
            ,baseCls: 'modx-formpanel'
            ,process: 'mgr/player/getSubscribers'
            ,standardSubmit: true
            ,url: '-'
            ,baseParams: { action: 'mgr/player/getSubscribers' }
            ,buttons: [{
                        text: 'Export er'
                        ,formBind: true
                        ,type: 'submit'
                        ,handler: function(){


                                var fp = this.ownerCt.ownerCt,
                                    form = fp.getForm();
                                if (form.isValid()) {
                                    // check if there are baseParams and if
                                    // hiddent items have been added already
                                    if (fp.baseParams && !fp.paramsAdded) {
                                        // add hidden items for all baseParams
                                        for (i in fp.baseParams) {
                                            fp.add({
                                                xtype: 'hidden',
                                                name: i,
                                                value: fp.baseParams[i]
                                            });
                                        }
                                        fp.doLayout();
                                        // set a custom flag to prevent re-adding
                                        fp.paramsAdded = true;
                                    }
                                    form.submit();
                                }

                    }
                    }]
       }, config);
        Players.panel.Subscription.superclass.constructor.call(this,config);
    }
  });

  var f = Ext.create(Players.panel.Subscription, {id:'formPanel', renderTo: Ext.getBody()});;
});
</script>
</body>
</html>

这篇关于单击提交按钮时,提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆