button run functions?

edited March 2, 2017 in Questions
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 !

Comments

  • edited March 2, 2017
    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);

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!