How to execute custom javascript code inside an rjs template

I'd like to execute a piece of javascript code, for example funcion f1() { alert('test'); }

in an rjs template

"page[:ticket_being_deleted].visual_effect :fade" I know this executes some javascript, but is there a way that instead of this javascript code, I execute f1 function?

Thanks in advance, Marko Vuksanovic.

There's an example for that here: #45 RJS Tips - RailsCasts, in the screencast but also in the piece of code on the webpage. Enjoy!

Aurels