Skip to content

Commit

Permalink
Merge pull request #51 from canjs/19-element-selector-docs
Browse files Browse the repository at this point in the history
Update docs to show that strings and array-likes can be used as arguments to canViewModel()
  • Loading branch information
bmomberger-bitovi authored Sep 6, 2017
2 parents e658acd + 8c95476 commit 8156f3a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions can-view-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ Gets the map instance associated with **element**, creating one as a [can-types.

```js
var vm = canViewModel(element);

var vm2 = canViewModel("#element2id");

var vm3 = canViewModel($([element3]));

var vm4 = canViewModel(document.querySelectorAll(".element4class"));
```
@param {HTMLElement} element Any element in the DOM.
@param {HTMLElement|String|ArrayLike} element Any element in the DOM, represented by a reference to the element itself, a query selector string, or an Array-like holding the element in its zero index.

@return {can-map|can-define/map/map|Object} The ViewModel associated with this element.

Expand All @@ -25,7 +31,7 @@ var foo = canViewModel(element, "foo");
console.log(foo); // -> "bar"
```

@param {HTMLElement} element Any element in the DOM.
@param {HTMLElement|String|ArrayLike} element Any element in the DOM, represented by a reference to the element itself, a query selector string, or an Array-like holding the element in its zero index.
@param {String} property The property to get from the ViewModel.

@return {*} The value of the property on the ViewModel or undefined if the property doesn’t exist.
Expand All @@ -42,7 +48,7 @@ var foo = canViewModel(element, "foo");
console.log(foo); // -> "bar"
```

@param {HTMLElement} element Any element in the DOM.
@param {HTMLElement|String|ArrayLike} element Any element in the DOM, represented by a reference to the element itself, a query selector string, or an Array-like holding the element in its zero index.
@param {String} property The property that is being set on the ViewModel.
@param {*} value The value being set on the property.

Expand Down

0 comments on commit 8156f3a

Please sign in to comment.