dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

v-vmOn directive not working #136

Closed Simcon closed 5 years ago

Simcon commented 5 years ago

I've taken the Vue FromScratch sample project and modified it to use the v-vmOn directive to call a method after a push event. The directive doesn't seem to get initialised correctly and the updateServerTime method is not called. Everything else works as expected:

<html>
  <head>
    <title>DotNetify</title>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, width=device-width" />
  </head>
  <body>
    <div id="App">
        <div>
            <p>{{Greetings}}</p>
            <p>Server time is: {{ServerTime}}</p>
            <p v-vmOn="{ ServerTime: updateServerTime }"></p>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script src="https://cdn.jsdelivr.net/npm/@aspnet/signalr@1/dist/browser/signalr.min.js"></script>
    <script src="https://unpkg.com/dotnetify@3/dist/dotnetify-vue.min.js"></script>

    <script>
      new Vue({
        el: '#App',
        created: function() { dotnetify.vue.connect("HelloWorld", this) },
        data: { Greetings: '', ServerTime: '' },
        methods: {
            updateServerTime: function (elem) {
                console.debug('updateServerTime updated');
            }
        }        
      })
    </script>
  </body>
</html>
dsuryd commented 5 years ago

Apparently the camel-case name v-vmOn only works inside a Vue template. Outside of it, you have to use kebab-case: v-vm-on.

Simcon commented 5 years ago

Yes, kebab-case works perfectly - thank you!