Onclick Component API
The onclick component renders an a tag that emits a client side event when the user clicks on it. The onclick component takes a block in order to define its appearance.

Parameters

emit - required

Takes a string or symbol. An event with this name will be emitted using the Matestack event hub.
You currently cannot pass in an event payload.

&block - required

The passed in block defines the appearance of the onclick component. The while UI structure defined in this block will be wrapped with an a tag

Examples

Emitting an event which triggers an asynchronous rerendering via async

1
class ExamplePage < Matestack::Ui::Page
2
3
def response
4
onclick emit: "abc" do
5
button "rerender something"
6
end
7
async rerender_on: "abc", id: "some-unique-id" do
8
plain "Render this text when the 'abc' event is emitted"
9
end
10
end
11
12
end
Copied!
Last modified 7mo ago