Threaded View

  1. #1
    Sencha User
    Join Date
    Dec 2012
    Vote Rating
    gendaful is on a distinguished road


    Default Answered: Having issue with calling a function from a buttonhandler inside a tabPanel

    Back Ground : I am working on an MVC application using sencha touch 2. I am working on a page which has two tabs. Inside the first tab, I have a button inside a title bar.
    Issue : I am not able to call anyother function from the button handler. I think, there is an issue with the scope of the calling function.

    Here is my code.

    extend: 'Ext.TabPanel',
    alias: 'widget.wuHomePageView',

    config: {
    fullscreen: true,
    defaults: {
    styleHtmlContent: true

    { // First Tab
    title: 'Home',
    iconCls: 'home',
    items: [
    xtype: 'titlebar',
    title: 'Hello',
    docked: 'top',
    items: [ {
    xtype: 'button',
    text: 'LogOut',
    ui: 'action',
    itemId: 'newButton',
    align: 'right',
    handler : function(btn)
    console.log('LogOut is tapped'); // This is printed
    this.up.onNewButtonTap(); // Throws error
    // Second Tab

    title: 'Contact',
    iconCls: 'user',
    html: 'Contact Screen'

    onNewButtonTap: function ()
    I am getting the error as below.

    Uncaught TypeError: Object function (selector)
    var result = this.parent;
    if (selector)
    for (; result; result = result.parent)
    { if (, selector))
    { return result;
    } } }
    return result; } has no method 'onNewButtonTap'

    I think there is an issue with setting the scope of a button. Kindly help.

    Thank you
    Last edited by gendaful; 13 Dec 2012 at 2:01 PM. Reason: Reformatted the code for better understanding

  2. There was an issue with the scope.

    I set xtype to the main container and then using that as a selector, i was able to call the function like below


Tags for this Thread