Skip to content

may be a bug of twoWay directive #631

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
suemi994 opened this issue Dec 12, 2014 · 4 comments
Closed

may be a bug of twoWay directive #631

suemi994 opened this issue Dec 12, 2014 · 4 comments

Comments

@suemi994
Copy link

When I define a twoWay directive and use set function in bind, there is an error 'can't read property set of undefined' , my code follows.

Vue.directive('tags',{
    twoWay:true,
    bind: function () {
        var self=this;
        console.log(self);
        $(self.el).on('itemAdded',function(){
             self.set($(this).val());
        });
    },

    unbind:function(){
        $(this.el).off();
    }
});
@suemi994
Copy link
Author

Even when I try the example in the guide, there are also those errors.

Uncaught TypeError: Cannot read property 'set' of undefined

@yyx990803
Copy link
Member

Yeah... this is a bug, but if you just give a an empty update function it should work. Also fixed in dev branch.

@EmaileriMikko
Copy link

@yyx990803 This still doesn't work.

See here for an example without update and here for a directive with update method.

@simplesmiler
Copy link
Member

@EmaileriMikko in Vue 2 directives no longer have this.
https://vuejs.org/v2/guide/migration.html#Custom-Directives-simplified

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants