2

I'm learning extjs as our application uses it. Right now I've been able to build something like:

blur: function(field, lastValues) {
  var vField = field.getValue(),
    vFormPanel = field.formPanel;

  if (Ext.isEmpty(vField)) {
    MsgBox.show({
        msgs: [{
          type: 'info',
          msg: Lang.getCustomFrameworkMessage('Do you want to search google?')
        }],
        buttons: MsgBox.YESNO,
        fn: function(buttonId) {
          if (buttonId === "yes") {
            var redirect = 'https://google.com'
            window.location.href = redirect;

          }
        }
      }
    }
  }
}

In the above code, when the field is tabbed in and out and is empty, it shows the message box. Instead I want that when the page is loaded, very then the message box should be displayed. How can that be done??

4

1 回答 1

2

您已经使用blur事件来做您的事情。您可以使用afterrender事件来显示您的消息。

这将取决于你在你的应用程序/用户界面中有什么,但一般的想法是查看你想要绑定的事件的文档,然后在那里添加你的处理程序。

这是一个示例应用程序:

Ext.application({
  name: 'Fiddle',
  launch: function() {
    Ext.create('Ext.panel.Panel', {
      title: 'Hello',
      width: 200,
      html: '<p>World!</p>',
      renderTo: Ext.getBody(),
      listeners: {
        afterrender: function() {
          Ext.Msg.alert('TEST')
        }
      }
    });
  }
});

这是 Sencha Fiddle 的演示

注意:演示和示例在 Sencha ExtJS 5.1

于 2018-08-16T01:49:59.683 回答