Uncaught TypeError: Невозможно прочитать свойство 'events' неопределенной кнопки ext js - PullRequest
0 голосов
/ 12 октября 2018

Я новичок в доп.Js, этот проект в ext js 3, я был бы признателен за опытную помощь.Проблема возникает в момент нажатия кнопки, она должна показать мне окно, но появляется ошибка:

Ошибка в консоли: Uncaught TypeError: Невозможно прочитать свойство 'events' of undefined

var drefdatosbuttonPDF = new Ext.Button({
        xtype: 'button',
        text: '<b style="color:black">&nbsp;&nbsp;&nbsp;Pdf&nbsp;&nbsp;</b>',
        iconCls: 'add',
        listeners: {
            click: function() {
                this.setText('I was clicked!');
                //FUNCION PAR ALLAMAR AL MODAL
                    SubirPDF();

            }   
        }

    });

Funcion: функция, которая показывает мне окно

function SubirPDF(){
            estudio_tipo_combo = true;
            fotoImageestudio="";
            var tfEstudioMostrar;
            var tituloVentana = 'Subir Legajo';

                    var tfTitulo = new Ext.form.TextField({
                        fieldLabel: 'T&iacute;tulo',
                        width: 400,
                        emptyText: ' ',
                        allowBlank: false,
                        vtype: 'uppercase'
                    });

            var dfFechaPostgrado = new Ext.form.DateField({
                fieldLabel: 'Fecha',
                width: 200,
                vtype: 'uppercase',
                allowBlank: false,
                emptyText: 'dd/mm/aa',
                maxValue: new Date(),
                minValue: dregdatosFechaNacimiento.getValue()
            });
            dfFechaPostgrado.setValue(new Date());


            var fbuttonestudios = new Ext.ux.form.FileUploadField({
                name: 'est_imagen',
                buttonText: '<center><b><i>Subir certificado</i></b></center>',
                width: 400,
                validator: function(v) {
                    if (!/\.png$/.test(v) && !/\.jpg$/.test(v) && !/\.JPG$/.test(v) && !/\.PNG$/.test(v)) {
                        return 'Solo se permite imágenes .png, .jpg, .pdf';
                    }
                    return true;
                },
                listeners: {
                    fileselected: function(fb, v) {
                        if (!window.FileReader) {
                            Ext.MessageBox.alert("Mensaje", "API no soportada por este navegador.");
                            return;
                        }
                        var d = new Date();
                        var n = d.getTime();

                        var fileInsimage="";
                        if(v.toString().indexOf("fakepath")!=-1){
                            var fileInsimage = v.toString().replace(/C:\\fakepath\\/, '');
                        }else{
                            var fileInsimage = v;
                        }

                        fotoImageestudio = 'estudio_' + n.toString() + parseInt(Math.random() * 1000).toString() + fileInsimage;
                        formimgestudios.getForm().submit({
                            url: 'modules/escalafon/m_docente.php',
                            waitMsg: 'Guardando',
                            params: {
                                nombrefoto: fotoImageestudio,
                                task: "subirestudio"
                            },
                            success: function(form, o) {
                                Ext.MessageBox.alert('Confirmaci&oacute;n', 'Se carg&oacute; el archivo correctamente.');
                            },
                            failure: function(form, o) {

                                Ext.MessageBox.alert('Error', 'Error al subir el archivo.');
                            }
                        });
                    }
                }
            });
            var formimgestudios = new Ext.form.FormPanel({
                bodyStyle: 'padding:0px;',
                layout: 'form',
                width: 600,
                id: 'formimgestudiosagregar',
                fileUpload: true,
                items: [fbuttonestudios]
            });
            // formulario para crear una tabla
            var formNuevoAcademico = new Ext.FormPanel({
                bodyStyle: 'padding:7px;',
                autoHeight: true,
                width: 600,
                layout: 'form',
                items: [tfEstudioMostrar, dfFechaPostgrado]

            });
            // ventana donde mostramos el formulario
            var windowNuevoAcademico = new Ext.Window({
                title: 'Agregar ' + tituloVentana,
                closable: false,
                width: 600,
                autoHeight: true,
                plain: true,
                layout: 'fit',
                modal: true,
                items: [formNuevoAcademico,formimgestudios],
                buttons: [
                    {
                        text: 'Grabar',
                        handler: function() {
                            if (!formNuevoAcademico.getForm().isValid()) {
                                Ext.MessageBox.alert('Alerta', 'Campos vacíos...');
                            } else
                            {
                                 /**especificar donde subir el pdf*/

                                windowNuevoAcademico.close();
                            }
                        }
                    }, {
                        text: 'Cancelar',
                        handler: function() {
                            if(fotoImageestudio.length!=0) {
                                Ext.Ajax.request({
                                    waitMsg: 'Procesando...',
                                    url: 'modules/escalafon/m_docente.php',
                                    params: {
                                        task: "eliminarTempImgUni",
                                        nombrefoto: fotoImageestudio
                                    }
                                });
                            }
                            windowNuevoAcademico.close();
                        }
                    }
                ]
            });
            windowNuevoAcademico.show();
        }
...