Call a function in a snippet from another snippet

  • 1
  • Question
  • Updated 3 years ago
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.

Cheers!

Louis
Photo of Louis Skelton

Louis Skelton

  • 4,786 Points 4k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Louis Skelton

Louis Skelton

  • 4,786 Points 4k badge 2x thumb
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.
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Photo of Louis Skelton

Louis Skelton

  • 4,786 Points 4k badge 2x thumb
Thanks Moshe! I'll give it a go and let you know how I get on.
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
I've used the pattern from Moshe's original post many times.  
Photo of Louis Skelton

Louis Skelton

  • 4,786 Points 4k badge 2x thumb
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!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
That's a bunch of pins on that map...