0

I am trying to create a back button that when the user clicks on it, it will take them to the previous page.

I found this code of a medium post by the author of Jasonett but it doesn't work for me. It creates the label but I can't click on it

"layers": [{
        "type": "label",
        "text": "",
        "style": {
          "top": "10",
          "right": "10",
          "width": "100",
          "height": "100"
        },
        "action": {
          "type": "$back"
        }
      }]
EzLo
  • 13,780
  • 10
  • 33
  • 38

1 Answers1

1

Source: The documentation

The element label is clickable or you can attach an action on a label only if it is at the item level.

So, for example, the following code will accept touch and the action set there would work fine.

{
  "items": [{
    "type": "label",
    "text": "Submit",
    "action": { SOME_ACTION } 
  }]
}

Where as the following won't accept a click.

{
  "items": [{
    "type": "vertical",
    "components": [{
      "type": "label",
      "text": "touch me",
      "action": { ... } 
    }]
  }]
}

In your example, label is defined inside layers. Thus it is not accepting a click.

Basically you have two options here.

  1. Implement a click handler in JasonLabelComponent.m so regardless of their position labels always respond to action if it is provided in JSON.
  2. Take the label out and make it a button, which by default would have action enabled.
Swagata Acharyya
  • 647
  • 4
  • 10