smocks icon indicating copy to clipboard operation
smocks copied to clipboard

How to use actions with global plugin?

Open zerkalica opened this issue 7 years ago • 3 comments

Example from documentation, i just change smocks.route to smocks.plugin:

    smocks.plugin({
      // ...
      input: {
        yourPhoneNumber: {
          label: 'What is your phone number?',
          type: 'text',
          defaultValue: '999.867.5309'
        }
      },

      // now define our action for the previous route
      actions: {
        'the_action_id': {
          label: 'the button label',
          input: {
            yourName: {
              label: 'What is your name?',
              type: 'text',
              defaultValue: 'John Doe'
            }
          },
          handler: function(config) {
            // this is how you access action specific user input
            var yourName = config.yourName;
            // this is how you access user input created for the route
            var phoneNumber = this.input('yourPhoneNumber');
            // now I would perform whatever action needs to be taken
            // I would make changes to "state" most likely (more about state later)
          }          
        }

      }
    })

Message on page /_admin : "There are no global actions"

zerkalica avatar Oct 07 '16 09:10 zerkalica