Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

v-on events are not working #13

Open
dkrasov opened this issue Nov 19, 2017 · 14 comments
Open

v-on events are not working #13

dkrasov opened this issue Nov 19, 2017 · 14 comments

Comments

@dkrasov
Copy link

dkrasov commented Nov 19, 2017

Hi!

I'm using your component, and I've noticed that v-on events (nor @change) are not working with your component, so I'm using watchers for my properties bound to switches.

The events support would be great improvement IMO.

@b4dnewz
Copy link

b4dnewz commented Dec 24, 2017

@dmitriymarley
you should use @input is not documented but you can find it in code

@DulanHewage
Copy link

[Vue warn]: Error in event handler for "input": "ReferenceError: array is not defined"

found in

---> at node_modules\vue-switches\src\switches.vue
at src\components\home.vue
at src\App.vue

help? I just wanna add an event listener

@b4dnewz
Copy link

b4dnewz commented Feb 7, 2018

@Dulan666 ensure that your "array" property which could possibly be in data or computed actually exists.. read the error message: array is not defined

@tophat1986
Copy link

@dkrasov Using emitters is needed because this is a component that must announce that an action is happening to other components. It's pretty easy to then "listen" to this data emitted and then perform whatever method or action you need. You can see example and setup here:

https://stackoverflow.com/questions/40300634/emit-an-event-from-child-to-parent-in-vue-js-es6-syntax

@antonioreyna
Copy link

how can i sent the current status and also an identifier?

@input="setStatus(id, isOn)"

for example?

@b4dnewz
Copy link

b4dnewz commented Feb 28, 2019

@antonioreyna you can use the $event keyword which contains the original event or in this case the updated value (i guess)

is that what you are looking for?

@antonioreyna
Copy link

@dkrasov yes! now i get my id and the value, but then the switch does not animate to the true or false value it keeps on OFF

@antonioreyna
Copy link

this is my switch code:

switches(color="green", :value="servicio.realizado",  :emit-on-mount="false", :type-bold="true", @input="setRealizado(servicio.id, $event)")

then on my method just:

setRealizado: function(id, event) {
            console.log('id', id);
            console.log('val', event);
}

@b4dnewz
Copy link

b4dnewz commented Feb 28, 2019

use v-model instead of v-value, otherwise you need to update it by yourself

@antonioreyna
Copy link

the thing is that my v-model in this case is a list of dates so if the date is null then the switch is off and if it is a date the switch is on, if i set it v-model it changes my date to true or false, can you tell me how do i update it manually then in my method?

thank you so much for your help

@b4dnewz
Copy link

b4dnewz commented Feb 28, 2019

setRealizado: function(id, event) {
            console.log('id', id);
            console.log('val', event);
            this.servicio.realizado = event
}

this in case event is the boolean switch value, to explain it a little bit, the v-value determine the "state" of the switch same as a normal checked attribute on a checkbox html input, when you toggle it the switch component react to its changes

@antonioreyna
Copy link

got it! i had to create a new array for my switches v-model but now its working thank you so much!

@b4dnewz
Copy link

b4dnewz commented Feb 28, 2019

ningún problema amigo

@abdullah-336
Copy link

abdullah-336 commented Mar 10, 2022

Hi!
@change is not working during the switching please resolve this issue. Thanks

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

No branches or pull requests

6 participants