Reputation: 33
I was just wondering if I could simplify this kind of code :
$(this).formWizard( {
onNext: function(tab, navigation, index) {
## My code
},
onLast: function(tab, navigation, index) {
## My code
},
...
})
to something like this or else :
$(this).formWizard( {
onNext, onLast: function(tab, navigation, index) {
## My code
}
})
I know there are other solutions, but is there a way to group several events to one function ?
Sorry for my English. Thank you for your help.
Upvotes: 2
Views: 65
Reputation: 831
No, this is not permitted by javascript syntax. The smartest will be to create a function and call it on the two events, as suggested by @wumm.
Upvotes: 2
Reputation: 14865
Why not save the function into a variable?
var myHandler = function(tab, navigation, index) {
// My code
};
$(this).formWizard( {
onNext: myHandler,
onLast: myHandler
})
Upvotes: 6