# ViewModel API example confusing; unify HTML + JS via \<script\>?

**URL:** <https://forums.bitovi.com/t/viewmodel-api-example-confusing-unify-html-js-via-script/909>\
**Category:** DocumentJS\
**Created:** [June 9, 2018, 2:51pm UTC](https://forums.bitovi.com/t/viewmodel-api-example-confusing-unify-html-js-via-script/909 "2018-06-09T14:51:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![code-read](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/code-read/32/111_2.png) [@code-read](https://forums.bitovi.com/u/code-read)\
**Post date:** [June 9, 2018, 2:51pm UTC](https://forums.bitovi.com/t/viewmodel-api-example-confusing-unify-html-js-via-script/909/1 "2018-06-09T14:51:19Z")

</div>

Here is a screenshot of [https://canjs.github.io/next/doc/can-component.prototype.ViewModel.html#CallingmethodsonViewModelfromeventswithintheview](https://canjs.github.io/next/doc/can-component.prototype.ViewModel.html#CallingmethodsonViewModelfromeventswithintheview). I like that a working example is provided, but find it hard to follow because items in the text sample are changed in the working example.

On a related note, I wonder if the working examples would be easier to follow if the HTML and JS sections were combined into a single HTML section which uses `<script>` to embed the JS?

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/donejs/original/1X/5ea3f002fb869bcba42076b97cf3d666b050844c.png)

---

<div class="post-metadata">

**Author:** ![chasen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/chasen/32/402_2.png) [@chasen](https://forums.bitovi.com/u/chasen)\
**Post date:** [June 11, 2018, 5:32pm UTC](https://forums.bitovi.com/t/viewmodel-api-example-confusing-unify-html-js-via-script/909/2 "2018-06-11T17:32:12Z")

</div>

Thanks @code-read! Would you mind filing an issue in the can-component repo? [https://github.com/canjs/can-component/issues/new](https://github.com/canjs/can-component/issues/new)

---

<div class="post-metadata">

**Author:** ![code-read](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/code-read/32/111_2.png) [@code-read](https://forums.bitovi.com/u/code-read)\
**Post date:** [June 11, 2018, 6:18pm UTC](https://forums.bitovi.com/t/viewmodel-api-example-confusing-unify-html-js-via-script/909/3 "2018-06-11T18:18:47Z")

</div>

Filed; let me know if I didn’t file it properly. Thanks.
