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
The `cable` component enables us to update the DOM based on events and data pushed via ActionCable without browser reload. Please read the [ActionCable Guide](/docs/guides/1000-action_cable/README.md) if you need help setting up ActionCable for your project.
3
+
The `cable` component enables us to update the DOM based on events and data pushed via ActionCable without a browser reload.
4
4
5
-
Please read the [ActionCable Guide](/docs/guides/1000-action_cable/README.md) if you need help setting up ActionCable for your project.
6
-
7
-
Please make sure to setup ActionCable correctly. Esspecially following implementation is important in order to use the `cable` component correctly:
5
+
Please read the [ActionCable Guide](/docs/guides/1000-action_cable/README.md) if you need help setting up ActionCable for your project, and make sure you have set up ActionCable correctly. The following code snippet is crucial to make the `cable` component work correctly:
Returns a vue.js driven cable component initially containing content specified by a block.
21
+
Returns a vue.js driven cable component, initially containing content specified by a block.
24
22
25
23
Imagine something like this:
26
24
@@ -29,8 +27,8 @@ class Page < Matestack::Ui::Page
29
27
30
28
defresponse
31
29
cable id:'foo' [...] do
32
-
#this block will be rendered as initial content
33
-
#and may be modified on the client later on when receiving defined events
30
+
#this block will be rendered as initial content and may be
31
+
#modified on the client side later upon receiving defined events
34
32
DummyModel.all.each do |instance|
35
33
list_component item: instance
36
34
end
@@ -39,16 +37,16 @@ class Page < Matestack::Ui::Page
39
37
end
40
38
```
41
39
42
-
with an as `list_component` registered component:
40
+
where the `list_component`is registered like this:
43
41
44
42
```ruby
45
43
classListComponent < Matestack::Ui::Component
46
44
47
45
requires :item
48
46
49
47
defresponse
50
-
#make sure to define a unique ID on the root element of your component
51
-
#this ID may be used to update or delete this component on the client later on
48
+
#make sure to define an unique ID on the root element of your component
49
+
# the declared ID may be used later on to update or delete this component on the client side
52
50
div id:"item-#{item.id}", class: "row"do
53
51
#...
54
52
end
@@ -57,132 +55,132 @@ class ListComponent < Matestack::Ui::Component
57
55
end
58
56
```
59
57
60
-
Please notice: when rendering a list of items, we recommend to use a custom component for each item. This makes it easy to render unique items on the serverside and push them via ActionCable to the client. But it is possible to also use another component or a html string. Any given html will be used to update the list.
61
-
58
+
Please note: When rendering a list of items, we recommend to use a custom component for each item. This makes it easy to render unique items on the serverside and push them via ActionCable to the client. Technically, it is also possible to use another component or a simple html string. Any given html will be used to update the item.
62
59
63
60
**Required options**
64
61
65
-
*`id` - Expects a unique string identifying the component
62
+
*`id` - Expects an unique string that identifies the component
66
63
67
64
**Optional options**
68
65
69
-
*`append_on` - Expects a string matching the event which will be emitted via ActionCable on the serverside. Event payload data in form of HTML will be **appended** to the current cable component DOM
66
+
*`append_on` - Expects a string that matches the event which will be emitted via ActionCable on the serverside. Event payload data in form of HTML will be **appended** to the current cable component DOM.
*`prepend_on` - Expects a string which matches the event which will be emitted via ActionCable on the serverside. Event payload data in form of HTML will be **prepended** to the current cable component DOM
90
+
*`prepend_on` - Expects a string that matches the event which will be emitted via ActionCable on the serverside. Event payload data in form of HTML will be **prepended** to the current cable component DOM.
*`replace_on` - Expects a string which matches the event which will be emitted via ActionCable on the serverside. Event payload data in form of HTML will **replace** the whole current cable component DOM
114
+
*`replace_on` - Expects a string that matches the event which will be emitted via ActionCable on the serverside. Event payload data in form of HTML will **replace** the whole current cable component DOM.
*`update_on` - Expects a string which matches the event which will be emitted via ActionCable on the serverside. Event payload data in form of HTML will **update** a specific element iditified by its root ID within the current cable component DOM
138
+
*`update_on` - Expects a string that matches the event which will be emitted via ActionCable on the serverside. Event payload data in form of HTML will **update** a specific element iditified by its root ID within the current cable component DOM.
*`delete_on` - Expects a string which matches the event which will be emitted via ActionCable on the serverside. Event payload data in form of a string containing the ID will **remove** a specific element identified by its root ID within the current cable component DOM
162
+
*`delete_on` - Expects a string that matches the event which will be emitted via ActionCable on the serverside. Event payload data in form of a string containing the ID will **remove** a specific element identified by its root ID within the current cable component DOM.
*Html attributes - all w3c confirm html attributes for div's can be set via options and will be added to the surrounding card div.
186
+
*`html attributes` - all the canonical [HTML global attributes](https://www.w3schools.com/tags/ref_standardattributes.asp)can be set via options and will be added to the surrounding cable div.
0 commit comments