1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    3
    Vote Rating
    0
    janksen is on a distinguished road

      0  

    Default how to add listeners for html dom in controller?

    how to add listeners for html dom in controller?


    When i tried to add listeners for html dom,but it doesn't work.
    this is my code:

    view:

    .....//some code
    items:
    [
    {
    docked: 'right',
    width: 104,
    id: 'test',
    html: ['<div class="grid_item grid_item_7 sidebtn" id="login_btn_exit">退出</div>',
    '<div class="grid_item grid_item_7 sidebtn" id="login_btn_delete" >删除</div>'].join('')
    }
    ]
    ....//some code

    //my controller code

    ....//some code

    init: function() {
    this.control({
    'div[id="login_btn_delete"]':
    {
    tap: this.onBtnExitTap
    },
    '#login_btn_delete':
    {
    tap: this.onBtnDeleteTap
    }
    },

    onBtnExitTap:function()
    {
    alert('exit');//it doesn't work
    },

    onBtnDeleteTap:function()
    {
    alert('delete'); // it doesn't work
    },

    sorry for my pool English,any body can understand my problem and give me some help?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,074
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    this.control can only listen to components as the string selector is a ComponentQuery selector.

    In order to do this, you have to add a listener to the element after it has been created.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2010
    Posts
    80
    Vote Rating
    0
    linuxyf is on a distinguished road

      0  

    Default


    var ojfile = document.getElementById('readjsonfile');
    ojfile.addEventListener("change", this.onReadJsonContent, false);

Thread Participants: 2