2012-04-19 6 views
0

チェックボックスにcheckeventを実行するためのヘルプが必要です。ここに私のコードは次のとおりです。checkbox checkeventの実行方法は?

View.js:

Ext.define('AM.view.shop.Bill', 
{ 
    extend: 'Ext.form.Panel', 
    alias : 'widget.bil', 
    title: 'Complete Check Out', 
    defaultType:'textfield', 
    initComponent: function() { 

    this.items= [ 
    // Mailing Address 
    { xtype: 'fieldset', 
     title: 'Mailing Address', 
     defaultType: 'textfield', 
     layout: 'anchor', 
     width:520, 
     defaults: { 
     anchor: '100%' 
    }, 

    items: [{ 
     fieldLabel: 'Street Address', 
     name: 'mailingStreet', 
     billingFieldName: 'billingStreet', 
     allowBlank: false 
    }, 

    { xtype: 'container', 
     layout: 'hbox', 
     items: [{ 
      xtype: 'textfield', 
      fieldLabel: 'City', 
      name: 'mailingCity', 
      id:'mailingCity', 
      billingFieldName: 'billingCity', 
      flex: 1, 
      allowBlank: false 
     }] 
    }] 
}, 

// Billing Address 
{ 
    xtype: 'fieldset', 
    title: 'Billing Address', 
    layout: 'anchor', 
width:520, 
    defaults: { 
     anchor: '100%' 
    }, 
    items: [{ 
     xtype: 'checkbox', 
     name: 'billingSameAsMailing', 
     boxLabel: 'Same as Mailing Address?', 
     hideLabel: true, 
     checked: true, 
     style: 'margin-bottom:10px', 
     id:'billingSameAsMailing', 
    }, 

    { xtype: 'textfield', 
     fieldLabel: 'Street Address', 
     name: 'billingStreet', 
     //style: 'opacity:.3', 
     disabled: true, 
     allowBlank: false 
    }, 

    { xtype: 'container', 
     layout: 'hbox', 
     items: [{ 
      xtype: 'textfield', 
      fieldLabel: 'City', 
      name: 'billingCity', 
      id:'billingCity', 
      style: (!Ext.isIE6) ? 'opacity:.3' : '', 
      flex: 1, 
      disabled: true, 
      allowBlank: false 
      }] 
     }] 
    }] 

    this.callParent(arguments); 
    } 
}); 

controller.js:

Ext.define('AM.controller.Shops', { 
    extend: 'Ext.app.Controller', 
    init: function() { 
     this.control({ 
      'bil textfield[name=mailingCity]' : { 
       change: function(textField) { 
        var formpanel = Ext.ComponentQuery.query('bil')[0]; 
        var copyToBilling = formpanel.down('[name=billingSameAsMailing]').getValue(); 

        if (copyToBilling) {  
         var city=formpanel.down('[name=mailingCity]').getValue(); 
         formpanel.down('[name=billingCity]').setValue(city); 
        }  
       }  
      }, 

      'bil checkbox[name=billingSameAsMailing]': { 
       check: function(item, checked) { 
        alert(item); 
       } 
       }      
      }); 
    } 
}); 

私は実行するための特定のチェックボックスを取得するには、テキストボックスの同じメソッドを使用しますイベントon
そのチェックボックス。テキストボックスでは正しく動作していますが、チェックボックスの場合は応答しません。

答えて

0

あなたは次のコードを試してみてください。それは私のために働く。

item.checked = true; 
関連する問題