Skip to content

Commit 6f077a8

Browse files
committed
Editing docs for View functions from index.md to getInnerHtml.md
1 parent cbf74a7 commit 6f077a8

12 files changed

+23
-23
lines changed

_fetcher/hydrate.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ example: Fetcher.hydrate(summaries, [options], callback)
55

66
This method is called when attaching views to the DOM, specifically when [attaching the child views](/view#attachChildViews). `hydrate` loops through each summary to retrieve the data from the corresponding [Model Store](/model-store) or [Collection Store](/collection-store) for each child view, then it invokes the specified callback.
77

8+
Hydration occurs either when the HTML has been loaded by the server, or when a view is creating an instance of a child view using a template adapter.
9+
810
Arguments:
911

1012
- `summaries` can be generated by the [Fetcher.summarize](#summarize) function.

_view/attachChildViews.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ header: attachChildViews
33
example: View.attachChildViews()
44
---
55

6-
Removes all child views, then looks at all of the child views that are expected and attaches each view.
6+
Removes all child views, then looks at all of the expected child views and attaches each view.

_view/attachOrRender.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ header: attachOrRender
33
example: View.attachOrRender(element, parentView)
44
---
55

6-
This is invoked when View is hydrating the [childViews](/#childViews). This will inspect the element and check to see if the view is lazy loaded or already attached. Hydration is the step where the HTML has been loaded by the server, or a view is creating an instance of a child view using a [template adapter](/template-adapters).
7-
8-
If neither of those are true, then it will see if the `data-render` attribute is set on the element. If it is, it will invoke the [render](#render) function. If not, it will call the [attach](#attach) function on the element.
6+
This is invoked when View is [hydrating](/fetcher/#hydrate) the [childViews](#childViews). This inspects the element to see if the view is lazy loaded or already attached. If neither of those are true, then it will check if the `data-render` attribute is set on the element. If it is, it will invoke the [render](#render) function. Otherwise it will call the [attach](#attach) function on the element.

_view/childViews.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ header: childViews
33
example: View.childViews
44
---
55

6-
An array of the views that are children of the view.
6+
An array of subviews of the view.

_view/constructor.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ header: constructor
33
example: new View([options])
44
---
55

6-
Creates a new instance of the View object. A required option is [app](/app) which is used in many of the helper functions throughout the view, and entire application.
6+
Creates a new instance of the View object. A required option is [app](/app) which is used in many helper functions throughout the view.
77

8-
The constructor will also intelligently retrieve [model](/model) and [collection](/collection) information. If you pass a JSON object with an ID and give it the `collection_name` or `model_name` options, it will retrieve that data from the corresponding store and set the inflated model / collection as the view attribute. For more information on parsing the model and collection attributes see [parseOptions](#parseOptions).
8+
The constructor will also intelligently retrieve [model](/model) and [collection](/collection) information. If you pass a JSON object with an id and give it the `collection_name` or `model_name` options, it will retrieve that data from the corresponding store and set the populated model / collection as an attribute on the view. For more information on parsing the model and collection attributes see [parseOptions](#parseOptions).
99

10-
The view constructor can have additional initialization information set by adding an `initialize` function. This is the same pattern developed in [Backbone's initialization](http://backbonejs.org/#View-constructor).
10+
You can set additional initialization information in the view constructor by adding an `initialize` function, just as in [Backbone's initialization](http://backbonejs.org/#View-constructor).
1111

12-
Another special option is `template_name`. This allows a point to hook in at to give a view a different template, by default this is `undefined`.
12+
Another special option is `template_name`, where you can set a different template for the view. By default this is `undefined`.

_view/decorateTemplateData.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ header: decorateTemplateData
33
example: View.decorateTemplateData(data)
44
---
55

6-
This function takes the result from [getTemplateData](#getTemplateData) and applies special properties to the data for the view. The special properties are `_app`, `_view`, `_model`, and/or `_collection`. These special properties are the instance variables for each of the options set on the view.
6+
This function takes the result from [getTemplateData](#getTemplateData) and applies special properties to the data for the view. The special properties are `\_app`, `\_view`, `\_model`, and/or `\_collection`: the instance variables for each of the options set on the view.
77

88
These are generally used in view helper functions, and for passing the instances to sub-views.

_view/fetchLazy.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ header: fetchLazy
33
example: View.fetchLazy()
44
---
55

6-
*Client-side only* To lazy load a view set the `lazy` option to true.
6+
*Client-side only* Set the `lazy` option to true to lazy-load a view.
77

88
<pre><code>var view = new View({
99
'lazy': true,
@@ -13,9 +13,9 @@ example: View.fetchLazy()
1313

1414
View options for enabling lazy loading:
1515

16-
- `lazy` - Set this to true to stop the server from trying to render the HTML server-side.
17-
- `fetch_params` - an object of parameters to send to the API for the model or collection
16+
- `lazy` - Set this to true to stop the server from trying to render the HTML server-side
17+
- `fetch_params` - An object of parameters to send to the API for the model or collection
1818
- `model_name` - This is used to make the fetch request for a model with the given parameters
19-
- `collection_name` - If you're requesting a collection, this is the name of the collection for the view.
19+
- `collection_name` - If you're requesting a collection, this is the name of the collection for the view
2020

21-
When the request begins, the `loading` class is added to the view, and triggers the `loading` event. [preRender](#preRender) is also invoked before the fetch request to the server. Once the data is retrieved from the server, if the view is still attached to the DOM, it will parse the results and [render](#render) the view.
21+
When the request begins, the `loading` class is added to the view, the `loading` event is triggered, and [preRender](#preRender) is invoked before the fetch request to the server. Once the data is retrieved from the server, if the view is still attached to the DOM, it will parse the results and [render](#render) the view.

_view/getChildViewsByName.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ header: getChildViewsByName
33
example: View.getChildViewsByName(name)
44
---
55

6-
This searches the [childViews](#childViews) attribute to return any children views that have a matching name. The function takes a string for the `name`, and returns an array of matches.
6+
This searches the [childViews](#childViews) attribute to return any children views that have a matching name. The function takes a string for the `name`, and returns an array of matches.
77

8-
Note: these must be the *exact* name of the view, if the view name includes a path or namespace, that must be included.
8+
Note: The argument must be the *exact* name of the view, including a path or namespace if those are present.
99

_view/getHtml.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ view.getHtml();
2020

2121
The Result: `'<a class="text-primary" data-additional-option="test">/* template */</a>'`
2222

23-
This function is expected to only be used on the server.
23+
This function should only be used on the server.

_view/getInnerHtml.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ example: View.getInnerHtml()
55

66
Turns the view's template into a string of HTML, without the wrapper element defined in the view itself.
77

8-
This will invoke the [preRender](#preRender) hook. Having the preRender invoked in `getInnerHtml` will ensure that it is invoked on client and server.
8+
This function invokes the [preRender](#preRender) hook, which ensures that `preRender` is invoked on client and server.

_view/nonAttributeOptions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ header: nonAttributeOptions
33
example: View.nonAttributeOptions
44
---
55

6-
These are options for the view that we don't want to create data-attributes for in the HTML. By default it's set to `['id', 'className', 'tagName']`, which are all attributes of the element itself. For more information about those specific elements checkout Backbone's [documentation](http://backbonejs.org/#View).
6+
These are options for the view that we don't want to create data-attributes for on the HTML element. By default it's set to `['id', 'className', 'tagName']`, which are all attributes of the element itself. For more information about those specific elements check out [Backbone's documentation](http://backbonejs.org/#View).

view/index.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ title: "View - RendrJS"
55

66
# View
77

8-
Views are the most powerful addition with Rendr. They have the ability to render HTML on the client or the server. This has a huge impact on performance, and with SEO. We can now render the same HTML on the client or the server, allowing web crawlers to work the same way a client-side Backbone application would.
8+
Views are the most powerful addition in Rendr. They are capable of rendering HTML on both the client and the server. This boosts the performance of your initial content load, and improves SEO by enabling web crawlers to easily crawl the contents of the rendered HTML, which has traditionally been a challenge with AJAX-loaded content in client-side Backbone applications.
99

10-
`Rendr.View` also hides a lot of the inner workings. Simply invoke the [render](#render) method of a view and it will re-render the template with the current state of the data and replace the HTML for you. There are also pre and post render hooks; [preRender](#preRender) and [postRender](#postRender).
10+
`Rendr.View` also hides a lot of the inner workings. Simply invoke the [render](#render) method of a view and it will re-render the template with the current state of the data. You can also write code in the [preRender](#preRender) and [postRender](#postRender) hooks provided.
1111

12-
Another performance boost comes with 'lazy-loading' views (see [fetchLazy](#fetchLazy)). The views that don't affect SEO or are secondary to data are prime views to lazy-load. When you lazy-load a view, it will wait to fetch data from the API until the page is loaded client-side. After fetching the data, it will automatically render the component it was defined.
12+
Another performance boost comes with 'lazy-loading' views (see [fetchLazy](#fetchLazy)). When you lazy-load a view, it will wait to fetch its data from the API until the page has finished loading on the client. After fetching the data, it will automatically render that component. The views that don't affect SEO or are secondary to data are prime views to lazy-load.
1313

1414
{% include pageDoc.html name="view" %}
1515

0 commit comments

Comments
 (0)