You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Show [specs](../../spec/usage/components/onclick_spec.rb)
4
4
5
-
The `onclick` component renders a div that runs a function on click. This is a nice component for use cases where you would like to wrap multiple components into one click function. The function called by the onclick component requires two fields. These two fields are `emit` and `data`. These two fields are then emitted as a event in javascript when the component is clicked
5
+
The `onclick` component renders a div that runs a function when the user clicks on it. This is a simple component that can be used to wrap components with a onclick function that will emit a event. The event that must be emitted onclick can defined by passing a hash into the `onclick` component that has the key `emit`. See example below for more details.
6
6
7
7
```ruby
8
8
classPages::MyPage::Home < Matestack::Ui::Page
9
9
defresponse
10
10
components{
11
-
onclick run_this_functiondo
11
+
onclick(emit:"abc")do
12
12
plain "Hello world"
13
13
end
14
14
}
15
-
end
16
-
17
-
defrun_this_function
18
-
return {
19
-
emit:"abc",
20
-
data: {
21
-
id:1,
22
-
name:"John",
23
-
detail:"Clicked the button"
24
-
}
25
-
}
15
+
async rerender_on:"abc"do
16
+
plain "Render this text when the 'abc' event is emitted"
0 commit comments