0

Simple question !

I have this function in my JS file

function getdata()
{
    Ext.Ajax.request(
    {
        url: '/app_dev.php/getdata',
        success: function (response)
        {
            console.log('réponse' + response.responseText);
        },
        failure: function (response, opts)
        {
            console.log('server-side failure with status code ' + response.status);
        }
    });
}

and then a menu with a listeners

menu: [
    {
        text: 'Import'
    },
    {
        text: 'Consultation',
        listeners:
        {
            click: function (getdata) {}
        },

Not working :(.
How can I call the function with clicking on the menu button ?
Please, I am aware this question is noob but don't put me some -1 :-).
From a guy trying to learn javascript !

1 Answer 1

1

The way you have it now getdata is just a parameter to the click handler and not the function you want calling.

You need to change it to something like this:

listeners: {
    click: function() { 
        getdata();
    }                                     
}

Or better yet:

listeners: {
    click: getdata                                    
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks you :) and excuse my newbness

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.