You call alert('test'); and assign it the return value of onclick . Use this instead:
onclick: function(){ alert('test'); }
Since I'm sure alert('test') is just an example, I should also point out that if you have the same problem with some function, you can probably just change your code:
onclick: somefunction()
To:
onclick: somefunction
You only need to wrap it in an anonymous function the way I did with alert('test'); if you pass arguments to a function other than the event object, which is usually passed to the event handler.
source share