|
37 | 37 |
|
38 | 38 | Now, you are able to create UI components in pure Ruby and use them in your Rails views. Additionally you can substitute Rails views and layouts with Matestack pages and apps.
|
39 | 39 |
|
40 |
| -If you want to use Matestack's optional reactivity features in pure Ruby \(through dynamic Vue.js components such as `form` and `async` or dynamic page transitions\), please perform the next steps to set up the JavaScript parts via AssetPipeline or Webpacker. |
| 40 | +If you want to use Matestack's optional reactivity features in pure Ruby \(through dynamic Vue.js components such as `form` and `async` or dynamic page transitions\), please perform the next steps to set up the JavaScript parts via Webpacker. |
41 | 41 |
|
42 | 42 | {% hint style="info" %}
|
43 | 43 | Matestack's JavaScript is only required if you want to use reactive features. It's totally valid to just use the "static" features of Matestack, namely implement UI components, pages and apps in pure Ruby.
|
@@ -81,9 +81,36 @@ $ bin/webpack --watch
|
81 | 81 | When you update the `matestack-ui-core` Ruby gem, make sure to update the npm package as well!
|
82 | 82 | {% endhint %}
|
83 | 83 |
|
84 |
| -### Turbolinks |
| 84 | +### Usage with Turbolinks/Turbo |
85 | 85 |
|
86 |
| -We recommend to \(remove/deactivate\)\([https://stackoverflow.com/a/38649595](https://stackoverflow.com/a/38649595)\) turbolinks within the scope you wish to build with Matestack, as there is no reason to use it alongside matestack-ui-core and there might appear some strange side effects. If you encounter strange page-transition/form-submit/action-submit behavior and have turbolinks activated, try to deactivate it first. |
| 86 | +If you want to use `matestack-ui-core` alongside with Turbolinks or Turbo, please add: |
| 87 | + |
| 88 | +```bash |
| 89 | +yarn add vue-turbolinks |
| 90 | +``` |
| 91 | + |
| 92 | +And use following snippet instead: |
| 93 | + |
| 94 | +```javascript |
| 95 | +import Vue from 'vue/dist/vue.esm' |
| 96 | +import Vuex from 'vuex' |
| 97 | + |
| 98 | +import MatestackUiCore from 'matestack-ui-core' |
| 99 | + |
| 100 | +import TurbolinksAdapter from 'vue-turbolinks'; // import vue-turbolinks |
| 101 | +Vue.use(TurbolinksAdapter); // tell Vue to use it |
| 102 | + |
| 103 | +let matestackUiApp = undefined |
| 104 | + |
| 105 | +// change the trigger event |
| 106 | +document.addEventListener('turbolinks:load', () => { |
| 107 | + matestackUiApp = new Vue({ |
| 108 | + el: "#matestack-ui", |
| 109 | + store: MatestackUiCore.store |
| 110 | + }) |
| 111 | +}) |
| 112 | + |
| 113 | +``` |
87 | 114 |
|
88 | 115 | ### Application layout adjustments
|
89 | 116 |
|
|
0 commit comments