Global Configuration

Global configuration allows you to set parameters once to be used multiple times. For example, if you have two click listeners on a page and you want both of them to work with the same recipe URL. Without using global configuration you code will look like this:

whisk.queue.push(function() {
    whisk.listeners.addClickListener(
        'add-to-list',
        'shoppingList.addRecipeToList',
        {
            recipeUrl: 'https://whisk.com/demo/calzone-roasted-peppers'
        }
    );
    whisk.listeners.addClickListener(
        'add-to-basket',
        'shoppingList.addRecipeToBasket',
        {
            recipeUrl: 'https://whisk.com/demo/calzone-roasted-peppers'
        }
    );
});

We can simplify it by using global configuration:

whisk.queue.push(function() {
    whisk.config.set('shoppingList', {
        recipeUrl: 'https://whisk.com/demo/calzone-roasted-peppers'
    });
    whisk.listeners.addClickListener('add-to-list', 'shoppingList.addRecipeToList');
    whisk.listeners.addClickListener('add-to-basket', 'shoppingList.addRecipeToBasket');
});      

Alternatively, you can use dots to set a single option:

whisk.queue.push(function() {
  whisk.config.set('shoppingList.styles.size', 'large');
});

Available Options

onlineCheckout object

styles object

button styles object

utm object

Last updated