Skip to content

Commit 43d17b7

Browse files
zachgarwoodJen Weber
authored andcommitted
Rearranged order of instructions in tutorial for actions (ember-learn#290)
* Rearranged order of instructions Following the instructions at the end of the Building a Simple Component page will temporarily leave the component in a non-functional state. This change rearranges the order of instructions so that the reader has a working application all the way through. * Made suggested changes * Moved changes to correct guide version * Revert "Made suggested changes" This reverts commit 9343d22c419763bdef89f79fcf848c320e200a4f. * Revert "Rearranged order of instructions" This reverts commit 99cfaefd6c59a0e65578eb8b93685efbba8a5918. * Added changes to new guide version (3.6)
1 parent f4e05bb commit 43d17b7

File tree

2 files changed

+54
-52
lines changed

2 files changed

+54
-52
lines changed

guides/v3.5.0/tutorial/simple-component.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,26 @@ export default Component.extend({
145145
});
146146
```
147147

148-
To allow the user to widen the image, we will need to add an action that toggles the value of `isWide`.
149-
Let's call this action `toggleImageSize`
148+
To allow the user to widen the image, we will need to add an action that toggles
149+
the value of `isWide`. Let's create the `toggleImageSize` action to toggle the
150+
`isWide` property on our component:
151+
152+
```javascript {data-filename="app/components/rental-listing.js" data-diff="-4,+5,+6,+7,+8,+9,+10"}
153+
import Component from '@ember/component';
154+
155+
export default Component.extend({
156+
isWide: false
157+
isWide: false,
158+
actions: {
159+
toggleImageSize() {
160+
this.toggleProperty('isWide');
161+
}
162+
}
163+
});
164+
```
165+
166+
In order to trigger this action, we need to use the `{{action}}` helper in our
167+
template:
150168

151169
```handlebars {data-filename="app/templates/components/rental-listing.hbs" data-diff="-2,+3,+4,+4,+6,+7"}
152170
<article class="listing">
@@ -177,31 +195,14 @@ Let's call this action `toggleImageSize`
177195
</article>
178196
```
179197

180-
Clicking the anchor element will send the action to the component.
181-
Ember will then go into the `actions` hash and call the `toggleImageSize` function.
182-
183-
An [actions hash](../../templates/actions/) is an object in the component that contains functions.
184-
These functions are called when the user interacts with the UI, such as clicking.
185-
186-
Let's create the `toggleImageSize` function and toggle the `isWide` property on our component:
187-
188-
```javascript {data-filename="app/components/rental-listing.js" data-diff="-4,+5,+6,+7,+8,+9,+10"}
189-
import Component from '@ember/component';
190-
191-
export default Component.extend({
192-
isWide: false
193-
isWide: false,
194-
actions: {
195-
toggleImageSize() {
196-
this.toggleProperty('isWide');
197-
}
198-
}
199-
});
200-
```
201-
198+
So, when we click on the anchor element, Ember will go into the `actions` hash
199+
and call the `toggleImageSize` function. An
200+
[actions hash](../../templates/actions/) is an object in the component that
201+
contains functions. These functions are called when the user interacts with the
202+
UI, such as clicking.
202203

203-
Now when we click the image or the `View Larger` link in our browser, we see our image show larger.
204-
When we click the enlarged image again, we see it smaller.
204+
So, when we click the image or the `View Larger` link in our browser, we see our
205+
image shown larger. When we click the enlarged image we again see it smaller.
205206

206207
![rental listing with expand](/images/simple-component/styled-rental-listings.png)
207208

guides/v3.6.0/tutorial/simple-component.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,26 @@ export default Component.extend({
145145
});
146146
```
147147

148-
To allow the user to widen the image, we will need to add an action that toggles the value of `isWide`.
149-
Let's call this action `toggleImageSize`
148+
To allow the user to widen the image, we will need to add an action that toggles
149+
the value of `isWide`. Let's create the `toggleImageSize` action to toggle the
150+
`isWide` property on our component:
151+
152+
```javascript {data-filename="app/components/rental-listing.js" data-diff="-4,+5,+6,+7,+8,+9,+10"}
153+
import Component from '@ember/component';
154+
155+
export default Component.extend({
156+
isWide: false
157+
isWide: false,
158+
actions: {
159+
toggleImageSize() {
160+
this.toggleProperty('isWide');
161+
}
162+
}
163+
});
164+
```
165+
166+
In order to trigger this action, we need to use the `{{action}}` helper in our
167+
template:
150168

151169
```handlebars {data-filename="app/templates/components/rental-listing.hbs" data-diff="-2,+3,+4,+4,+6,+7"}
152170
<article class="listing">
@@ -177,31 +195,14 @@ Let's call this action `toggleImageSize`
177195
</article>
178196
```
179197

180-
Clicking the anchor element will send the action to the component.
181-
Ember will then go into the `actions` hash and call the `toggleImageSize` function.
182-
183-
An [actions hash](../../templates/actions/) is an object in the component that contains functions.
184-
These functions are called when the user interacts with the UI, such as clicking.
185-
186-
Let's create the `toggleImageSize` function and toggle the `isWide` property on our component:
187-
188-
```javascript {data-filename="app/components/rental-listing.js" data-diff="-4,+5,+6,+7,+8,+9,+10"}
189-
import Component from '@ember/component';
190-
191-
export default Component.extend({
192-
isWide: false
193-
isWide: false,
194-
actions: {
195-
toggleImageSize() {
196-
this.toggleProperty('isWide');
197-
}
198-
}
199-
});
200-
```
201-
198+
So, when we click on the anchor element, Ember will go into the `actions` hash
199+
and call the `toggleImageSize` function. An
200+
[actions hash](../../templates/actions/) is an object in the component that
201+
contains functions. These functions are called when the user interacts with the
202+
UI, such as clicking.
202203

203-
Now when we click the image or the `View Larger` link in our browser, we see our image show larger.
204-
When we click the enlarged image again, we see it smaller.
204+
So, when we click the image or the `View Larger` link in our browser, we see our
205+
image shown larger. When we click the enlarged image we again see it smaller.
205206

206207
![rental listing with expand](/images/simple-component/styled-rental-listings.png)
207208

0 commit comments

Comments
 (0)