Element: el-select @change event is broken since 1.0.4

Created on 8 Dec 2016  ·  5Comments  ·  Source: ElemeFE/element

ElementUI version

1.0.4 and 1.0.5

OS/Browers version

Windows 10/Chrome 54.0.2840.99 m

Vue version

2.1.4

Reproduction Link

https://jsfiddle.net/hq4scjto/1/

Steps to reproduce

Select any of the options within the selectbox. This worked perfectly up until 1.0.3.

What is Expected?

Change event handler should be invoked

What is actually happening?

Change event is ignored

question

Most helpful comment

In this case, try changing change to input: https://jsfiddle.net/hq4scjto/6/
Select without v-model should not fire change event (it's actually a bug if versions prior to 1.0.3 does). #1508 talks about a similar scenario.

All 5 comments

I think you are using it wrong.

<el-select :value="value" @change="update">

To bind a variable to Select, one should use v-model, not :value. And, inside the update method:

update: function (selected) {
  value = selected
}

I wonder what the purpose of this callback is. Because selected always equals to value when the change event fires. Besides, to access value, one should use this.value. A working demo: https://jsfiddle.net/hq4scjto/4/

Also, 1.0.3 doesn't work perfectly in this case: https://jsfiddle.net/hq4scjto/5/ . You can see from the console that this.value never changes.

Sorry but I'm using vuex andv-model simply does not work in this scenario. As far as I know v-model is just a syntactic sugar to binding a value along with a change event so I was expecting this to work and it actually did. I was using the @change event and it worked perfectly with vuex mutations. Same for :value with vuex getters. 1.0.4 broke it for sure. So is it something that you would be willing to take a look at?

Regarding your example with 1.0.3 this.value never changes because , just like in my first jsfiddle, value was out of scope. Please take a look at this https://jsfiddle.net/6Lccqqfp/1/ and see that it actually works in 1.0.3. Same is impossible with 1.0.4 or 1.0.5. The @change event is just not triggered - and that is the only thing that's been broken.

In this case, try changing change to input: https://jsfiddle.net/hq4scjto/6/
Select without v-model should not fire change event (it's actually a bug if versions prior to 1.0.3 does). #1508 talks about a similar scenario.

It makes sense now. Swapping change to input works like a charm. Thanks for your help.

image
My input will be triggered,But when the input triggers the update of the data source,Value is not re-rendered

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mochenxm picture mochenxm  ·  3Comments

chao-hua picture chao-hua  ·  3Comments

smallpath picture smallpath  ·  3Comments

zhguokai picture zhguokai  ·  3Comments

yubo111 picture yubo111  ·  3Comments