質問

Hi i am new for sencha touch. Please see my code below

    Ext.define('blackbutton.view.Login.Login', {
extend: 'Ext.Container',
xtype: 'loginview',
id:'loginview',
requires: [    
  'Ext.field.Password',
  'blackbutton.store.Login.LoginLS'
],

config: {
    style: 'background-color:#0B0B0C',
    cls: 'core',
    scrollable: {direction: 'vertical', directionLock: true},
     html      : '<section class="nt_contentWrap">'+

     ' <img src="resources/images/profile_header_signup.jpg" width="320" height="142"  alt=""/> <br>'+
      '<br>'+
        '<span class="title"> Login           </span> '+
  ' <ul class="ul-na">'+
          ' <li><input type="text" placeholder="Email" name="bbid"></li>'+

          ' <li>'+
  ' <input type="text" placeholder="Password"  maxlength="11" name="bbpassword"></li>'+
 '</ul>'+


'<button type="signup" id="login">Log In</button>'+
'<button type="signup" id="sigup" >Sign up</button>'+




'</section>',

    listeners : [
        {
            element  : 'element',
            delegate : 'button#sigup',
            tap      : function () {
                alert('test');
            }
        },
        {
            element  : 'element',
            delegate : 'button#login',
            tap      : function () {
                alert('login');
            }
        }

    ]
    }

    });

I need to add listener for two button. Which are signup button and login button. The tap event seem like no fire.

However if i add listener for one button only.

listeners : 
{
    element  : 'element',
    delegate : 'button#sigup',
    tap      : function () {
        alert('test');
    }
}

The tap event for signup button is able to fire. Any idea?

役に立ちましたか?

解決

You can do the following trick according to the target ID

listeners: {
    tap: {
                element: 'element',
                delegate: ['button#sigup', 'button#login'],
                fn: "DoSomething"
         }

 }


//.....

function DoSomething(e){
  if (e.target.id=="sigup"){
    //signup
  }
  else{
    //login
  }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top