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
Copy file name to clipboardExpand all lines: docs/api/000-base/40-isolated_component.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,7 +155,7 @@ With `init_on` you can specify events on which the isolate components gets initi
155
155
156
156
#### public_options
157
157
158
-
You can pass data as a hash to your custom isolate component with the `public_options` option. This data is inside the isolate component accessible via a hash with indifferent access, for example `public_options[:item_id]`. All data contained in the `public_options` will be passed as json to the corresponding vue component, which means this data is visible on the client side as it is rendered in the vue component config. So be careful what data you pass into `public_options`!
158
+
You can pass data as a hash to your custom isolate component with the `public_options` option. This data is inside the isolate component accessible via a hash with indifferent access, for example `public_options[:item_id]`. All data contained in the `public_options` will be passed as json to the corresponding Vue.js component, which means this data is visible on the client side as it is rendered in the Vue.js component config. So be careful what data you pass into `public_options`!
159
159
160
160
Due to the isolation of the component the data needs to be stored on the client side as to encapsulate the component from the rest of the UI.
161
161
For example: You want to render a collection of models in single components which should be able to rerender asynchronously without rerendering the whole UI. Since we do not rerender the whole UI there is no way the component can know which of the models it should rerender. Therefore passing for example the id in the public_options hash gives you the possibility to access the id in an async request and fetch the model again for rerendering. See below for examples.
@@ -346,7 +346,7 @@ With `init_on: 'init_time'` you can specify an event on which the isolated compo
346
346
347
347
### Example 6 - Use custom data in isolated components
348
348
349
-
Like described above it is possible to use custom data in your isolated components. Just pass them as a hash to `public_options` and use them in your isolated component. Be careful, because `public_options` are visible in the raw html response from the server as they get passed to a vue component.
349
+
Like described above it is possible to use custom data in your isolated components. Just pass them as a hash to `public_options` and use them in your isolated component. Be careful, because `public_options` are visible in the raw html response from the server as they get passed to a Vue.js component.
350
350
351
351
Lets render a collection of models and each of them should rerender when a user clicks a corresponding refresh button. Our model is called `Match`, representing a soccer match. It has an attribute called score with the current match score.
352
352
@@ -401,5 +401,5 @@ end
401
401
```
402
402
403
403
This page will render a match_isolated_score component for each match.
404
-
If one of the isolated components gets rerendered we need the id in order to fetch the correct match. Because the server only resolves the isolated component instead of the whole UI it does not know which match exactly is requested unless the client requests a rerender with the match id. This is why `public_options` options are passed to the client side vue component.
404
+
If one of the isolated components gets rerendered we need the id in order to fetch the correct match. Because the server only resolves the isolated component instead of the whole UI it does not know which match exactly is requested unless the client requests a rerender with the match id. This is why `public_options` options are passed to the client side Vue.js component.
405
405
So if match two should be rerendered the client requests the match_isolated_score component with `public_options: { id: 2 }`. With this information our isolated component can fetch the match and rerender itself.
Copy file name to clipboardExpand all lines: docs/api/100-components/form.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -932,9 +932,9 @@ end
932
932
933
933
```
934
934
935
-
## Form and other VueJs components
935
+
## Form and other Vue.js components
936
936
937
-
The child components `form_*` have to be placed within the scope of the parent `form` component, without any other VueJs component like `toggle`, `async` creating a new scope between the child component and the parent form component**
937
+
The child components `form_*` have to be placed within the scope of the parent `form` component, without any other Vue.js component like `toggle`, `async` creating a new scope between the child component and the parent form component**
@@ -7,10 +7,10 @@ Welcome to the ninth part of our tutorial about building a web application with
7
7
8
8
## Introduction
9
9
10
-
In a [previous guide](/docs/guides/100-tutorial/08_collection_async.md), we introduced custom components. In this one, we're bringing it to the next level with custom vue.js components!
10
+
In a [previous guide](/docs/guides/100-tutorial/08_collection_async.md), we introduced custom components. In this one, we're bringing it to the next level with custom Vue.js components!
11
11
12
12
In this guide, we will
13
-
- add a custom vue.js component that fetches and displays data from a third-party API
13
+
- add a custom Vue.js component that fetches and displays data from a third-party API
14
14
15
15
## Prerequisites
16
16
@@ -20,9 +20,9 @@ We expect you to have successfully finished the [previous guide](/docs/guides/10
20
20
21
21
We want to display an option for what you could do with the person at its show page. Therefore we want to fetch a json api and display content of the responses on the page.
22
22
23
-
We can achieve this by creating a custom vue.js component. A custom vue.js component is different from a custom component in the way that it needs a corresponding javascript file, which implements the frontend counterpart of our custom vue.js component.
23
+
We can achieve this by creating a custom Vue.js component. A custom Vue.js component is different from a custom component in the way that it needs a corresponding javascript file, which implements the frontend counterpart of our custom Vue.js component.
24
24
25
-
Okay, let's create our custom vue.js component. First we create a component in `app/matestack/components/persons/activity.rb`.
25
+
Okay, let's create our custom Vue.js component. First we create a component in `app/matestack/components/persons/activity.rb`.
@@ -46,10 +46,10 @@ class Components::Persons::Activity < Matestack::Ui::VueJsComponent
46
46
end
47
47
```
48
48
49
-
Our vue.js component renders a div containing a paragraph and a list. The paragraph contains some text and a button. We set a `v-on:click` event handler like you would normally do in vue.js with its shorter version `@click`. This means the button will call the `addActivity` method from its corresponding vue.js component. In the list below we assume that our javascript vue.js component has an `activities` array. We loop over it, again using vue.js directives and display each activity with a button labelled 'Remove' which calls `deleteActivity(index)` if clicked.
49
+
Our Vue.js component renders a div containing a paragraph and a list. The paragraph contains some text and a button. We set a `v-on:click` event handler like you would normally do in Vue.js with its shorter version `@click`. This means the button will call the `addActivity` method from its corresponding Vue.js component. In the list below we assume that our javascript Vue.js component has an `activities` array. We loop over it, again using Vue.js directives and display each activity with a button labelled 'Remove' which calls `deleteActivity(index)` if clicked.
50
50
51
51
Like stated above, a `Matestack::Ui::VueJsComponent` requires a javascript counterpart.
52
-
Inside we define a vue.js component and give it a name. The name needs to equal the name we defined in our ruby component at the top with `vue_js_component_name`. This settings is necessary in order to connect the javascript component with our ruby component.
52
+
Inside we define a Vue.js component and give it a name. The name needs to equal the name we defined in our ruby component at the top with `vue_js_component_name`. This settings is necessary in order to connect the javascript component with our ruby component.
53
53
Let's create it aside our ruby component in `app/matestack/components/persons/activity.js`
As you can see, we're making use of [The Bored API](https://boredapi.com) to fill an (initially empty) array with strings. The `addActivity` method calls the api and pushes the activity from the response into the activities array. Because vue.js is reactive, our list specified in the ruby component will be updated and contain the added activity. Clicking the delete button will remove the activity and therefore remove the entry from the list.
82
+
As you can see, we're making use of [The Bored API](https://boredapi.com) to fill an (initially empty) array with strings. The `addActivity` method calls the api and pushes the activity from the response into the activities array. Because Vue.js is reactive, our list specified in the ruby component will be updated and contain the added activity. Clicking the delete button will remove the activity and therefore remove the entry from the list.
83
83
84
84
After creating the new component, we still need to register it, both in the `/app/matestack/components/registry.rb`
85
85
@@ -142,9 +142,9 @@ Again, don't forget to save your progress to Git. In the repo root, run
142
142
git add .&& git commit -m "Add activity dynamic component to display activities from The Bored API"
143
143
```
144
144
145
-
## More information on custom vue.js components
145
+
## More information on custom Vue.js components
146
146
147
-
The existing components inside matestack aim to cover as many use cases as possible, abstracting away most of the JavaScript for generic, recurring use cases. This way, you can stick to Ruby logic and focus on building business logic instead of re-implementing basic JavaScript functionality. There sometimes is, however, a valid case for specific, handcrafted client side functionality. Therefore, matestack offers the option of creating custom vue.js components. Go ahead and [check the Vue.js guides](https://vuejs.org/v2/guide/) if you have never used it before.
147
+
The existing components inside matestack aim to cover as many use cases as possible, abstracting away most of the JavaScript for generic, recurring use cases. This way, you can stick to Ruby logic and focus on building business logic instead of re-implementing basic JavaScript functionality. There sometimes is, however, a valid case for specific, handcrafted client side functionality. Therefore, matestack offers the option of creating custom Vue.js components. Go ahead and [check the Vue.js guides](https://vuejs.org/v2/guide/) if you have never used it before.
148
148
149
149
As with custom components, there are hardly any limits for your creativity. You can also
150
150
- use `haml` (and in the future `slim` and `erb`) for templating
@@ -156,6 +156,6 @@ To learn more, check out the [basic building blocks](/docs/guides/200-200-basic_
156
156
157
157
## Recap & outlook
158
158
159
-
In this guide, we introduced custom vue.js components - an option for you to bring more complex JavaScript functionality to your application by extending matestacks components with your own Vue.js components.
159
+
In this guide, we introduced custom Vue.js components - an option for you to bring more complex JavaScript functionality to your application by extending matestacks components with your own Vue.js components.
160
160
161
161
Let's go ahead and learn how to best add [styling and notifications](/docs/guides/100-tutorial/10_styling_notifications.md) to our application in the next part of the series!
0 commit comments