Call a function in a snippet from another snippet

If I have a function in a snippet that is called on page load, how do I then refer back to that function from an in-line snippet triggered, for example, by the action framework?

Forgive me if I’m being horribly daft.



To provide an example: I’m populating a series of markers for each record in a model on a Google Map. I’m placing those markers in an array. This all occurs on page load. I then want to clear that array via a snippet on a button.

Sounds like this :

Thanks Moshe! I’ll give it a go and let you know how I get on.

I’ve used the pattern from Moshe’s original post many times.  

Thanks again Moshe, registering snippets in one js resource and calling them from the action frame-work made this a whole lot easier to put together. Cheers!

That’s a bunch of pins on that map…