Threaded View

  1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    30
    Answers
    6
    Vote Rating
    2
    gendaful is on a distinguished road

      0  

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

    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.

    Ext.define('WUPOC.view.WUHomePage',
    {
    extend: 'Ext.TabPanel',
    requires:['Ext.TitleBar','Ext.dataview.List','Ext.data.proxy.JsonP'],
    alias: 'widget.wuHomePageView',

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

    items:
    [
    { // 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 ()
    {
    console.log('newNoteCommand');
    },
    });
    I am getting the error as below.

    Uncaught TypeError: Object function (selector)
    {
    var result = this.parent;
    if (selector)
    {
    for (; result; result = result.parent)
    { if (Ext.ComponentQuery.is(result, 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
    this.up('myXType').onNewButtonTap();

    Thanks

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi