Call a Snippet from HTML in a Template

  • 1
  • Question
  • Updated 4 years ago
  • Answered
Figured out how to call a js (inline) snippet from HTML in a template component:
var loadMoreFunc = skuid.snippet.getSnippet('loadMore');
<center><a href="javascript:loadMoreFunc();">Load More...</a></center>
My question is whether or not there is a more straight-forward way to do this?
This just seems unnecessary.
Any help is appreciated.  
Photo of Mark Tucker

Mark Tucker

  • 422 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,432 Points 50k badge 2x thumb
Official Response
Okay Mark my previous post actually didn't work. get() and getSnippet() do the same thing, one's just a shortcut for the other. The thing that was missing is that calling getSnippet() returns you a function. You have to actually invoke the function with () in order for it to do something. I get tripped up by that on occasion as well. So here's the correct version:

<center><a href="javascript:skuid.snippet.getSnippet('loadMore')();">Load More...</a></center>