Reputation: 57
I learn jquery not long time. Help please to put variable instead object method.
return {
label: item.MYVariable,
}
I need instead of MYVariable
put dynamic variables.
Upvotes: 1
Views: 60
Reputation: 337560
Assuming I've understood your question correctly, you can use bracket notation to access the variables, like this:
var foo = 'MYVariable';
return {
label: item[foo];
}
Upvotes: 2