2013-10-08 51 views
0

在这里我已经在sencha应用程序中使用的代码,因为我想添加一个提醒提示输入您的密码!当indexpnl launch.Here代码在启动警报

var mainContainer = Ext.create('Ext.Panel', { 
    id: 'mainContainer', 
    layout: 'card', 
    width: '100%', 
    height: '100%', 
    showAnimation: { 
        type: 'slideIn', 
        direction: 'right' 
        }, 
    items: [indexpnl,loginpnl,registerpnl,homepnl,viewitemspnl,forgpanel,myfriendpro,notifypanel,mapapnel,friendviewitemspnl] 
    }); 
    Ext.Viewport.add({ 
     xtype: 'panel', 
     items: [mainContainer] 
    }); 

警报

function alertprompt() 
{ 
var retVal = prompt("Enter your password? ", "Password"); 
} 

当应用程序启动indexpnl显示first.I要显示与that.Where上述警告,我应该要调用的方法alertprompt()显示在启动?PLease帮助解决这个问题

回答

1

我假设你打电话Ext.onReady();来调用你的功能,显示indexpnl

让我们假设这个函数是start()。如果您使用的发射功能添加到的xtype视口{

  afterrender:function(t,eOpts){ 

      alert("Enter your password"); 

     } 

     } 
0

嗨,你可以使用这个监听器只需要添加下面的代码

听众。你可以在那里使用“Ext.Msg.prompt(...)”。密码获取成功后,您可以将pannel添加到视口中。注意:我假设您将在密码验证后显示主容器。 如:`

launch:function(){ 
    Ext.Msg.prompt('Authentication Process!','Please enter your password:', function(button,text){ 
     if(button=='ok'){ 
     //Do your password validation here. Then add your panel into the Viewport 
     } 
     else 
     { 
     Ext.Msg.alert('Reload the application and give your password'); 
     } 
    }); 
    }, 

`

+0

我应该在哪里要在主容器 – Fazil

+0

它不工作 –

+0

添加此监听器......在mainContainer上或Ext.Viewport.add – Fazil

0

function start() { 
    //do your panel rendering to where ever 
    alertprompt(); 
} 
+0

是的。密码验证后,我想显示主容器。在哪里,我应该显示警报以及如何 – Fazil

+0

我已经添加了示例代码如何添加提示信息为您的验证。这个函数应该在app.js文件中定义。 – prakash