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

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

      0  

    Default Got the issue.

    Got the issue.


    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

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar