V
V
Vadim Sutormin2020-03-03 13:37:33
Vue.js
Vadim Sutormin, 2020-03-03 13:37:33

How to make an object see new v-on event handlers in Vue?

I create an org object that has an orgajax method - it pulls data from the server, including HTML code that contains buttons with a link to the same method, like v-on:click="orgajax(''select, 19) ". Since our object has already been created, it does not see these directives, how to make them see? I understand that I need to somehow update the object and created a second then in orgajax. Tell me what to push there or how to update the object in another way?

var org = new Vue({
       el: '#orgForm',
       data: {
           Feed: '',
           Current: {
           }
       },
       methods: {
            orgajax: function(mode, id) {
                alert('!!!!');
                axios
                    .post('/api/?version=3', {task: 'vue-salary-org', mode: mode, id: id, data: this.Current})
                    .then(response => {
                        this.Feed = response.data.html;
                        this.Current = response.data.current;
                        //$('#orgModal').modal('show');
                    })
                    .then(function () {

                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            }
       },
       created: function () {
            this.orgajax();
       }

   });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-03-03
@Wunder

there is an orgajax method - it pulls data from the server, including HTML code

And should - just data, on the basis of which the markup will be created already on the client. Redo.
Well, or you can go the way of the govnocoder - compile the resulting templates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question