Reputation:
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 !
Upvotes: 0
Views: 3859
Reputation: 29668
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
}
Upvotes: 1