button run functions?

  • 1
  • Question
  • Updated 4 years ago
  • Answered
As my code gets more mature generic sequences are turning into functions of global objects... so I end up with snippets that look like this
Cal.popup_cancel();
Is is possible that you might add the option of running a function rather than a snippet on a button click ? It would save having to recreate these generic snippets for every form, for every popup.

Thanks for all your great work !
Photo of ktyler

ktyler

  • 9,244 Points 5k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
You could define these "utility functions" as Skuid Snippets, rather than global functions. Then you could run these "utility snippets" within various other snippets, for example say that you have Inline Javascript like this:


(function(skuid){
var $ = skuid.$;
var registerSnippet = skuid.snippet.registerSnippet;
var getSnippet = skuid.snippet.getSnippet;
//
// UTILITY SNIPPETS
//
registerSnippet('Cal.popup_cancel',function(){
    // CODE GOES HERE
});
registerSnippet('Cal.popup_save',function(){
    // CODE GOES HERE
});
//
// SPECIFIC SNIPPETS
//
registerSnippet('testPage.eventPopup.closePopupButton',function(args){
    // Do some stuff
    
    var result = true;
    
    // Then run our utility snippet
    if (result === true) {
        getSnippet('Cal.popup_cancel')(args);
    } else {
        getSnippet('Cal.popup_save')(args);
    }
});


})(skuid);



(Edited)