【问题标题】:Not able to get reference to form in sencha无法在煎茶中获得对表格的参考
【发布时间】:2014-03-14 15:05:16
【问题描述】:

我正在尝试通过单击按钮重置表单。 按钮的功能在文件单独的控制器文件中定义。 但是在单击按钮重置时我得到错误 “未捕获的 TypeError:对象 form1orig 没有方法‘reset’”

Controller
    Ext.define('myapp.controller.form1', {
    extend: 'Ext.app.Controller',
    requires: [
    'myapp.view.form1'
    ],
    config: {
        refs: {
        form1orig: '#pressc',
        form1Submit: 'button[action=sub]',
        form1Reset: 'button[action=res]'
          },
    control: {
    'form1Reset' : {
      tap: 'onForm1Reset'
    },
  'form1Submit' : {
      tap: 'onForm1Submit'
    }     
    }
},

onForm1Reset: function(button){
  'form1orig'.reset();
  console.log('Tapped reset');

},
  onForm1Submit: function(button){

console.log('Tapped submit');

}

});

查看

Ext.define('myapp.view.form1', {
extend: 'Ext.form.Panel',

requires: [
    'Ext.form.FieldSet',
],
xtype: 'form1Me',
id: 'form1Me',
config: {
    items: [
        {
            xtype: 'fieldset',
            id: 'pressc',
            instructions: 'Please enter the information above.',
            defaults: {
                labelWidth: '35%'
            },
            items: [
                {
          xtype:'textfield',
          name: 'name',
          label: 'Name',
          id: 'eman',
          placeHolder: 'Name'
        },

        {
                    xtype: 'textareafield',
                    name : 'Prescription',
        id: 'pres',
                    label: 'Prescription',
                    placeHolder: 'Enter your prescription here...'          
                }
            ]
        },

        {
            xtype: 'container',
            defaults: {
                xtype: 'button',
                style: 'margin: .5em',
                flex : 1
            },
            layout: {
                type: 'hbox'
            },
            items: [
                {

          text: 'Submit',
          id: 'subMe',
          action: 'sub',
                    scope: this,
                    hasDisabled: false
                    //handler: function(btn){

          /*var presscForm = Ext.getCmp('presscForm');
          presscForm.submit({
            url: '../../result.php',
            method: 'POST', 
            success: function() {
              alert('Thamk you for using our service');
            }
          });*/
          //}
                },
                {
                    text: 'Reset',
        id: 'resMe',
        action: 'res'
                    /*handler: function(){
                        Ext.getCmp('form1Me').reset();
                    }*/
                }
            ]
        }
    ]
}
});

帮助

【问题讨论】:

    标签: forms extjs ext4


    【解决方案1】:

    你应该这样做:

    var form = Ext.ComponentQuery.query('form1Me');
    form.reset();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-29
      • 2012-06-22
      • 2011-06-11
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      相关资源
      最近更新 更多