vitalets / angular-xeditable

Edit in place for AngularJS
http://vitalets.github.io/angular-xeditable
MIT License
1.91k stars 402 forks source link

Select doesn't support string as status.value #761

Open sinall opened 5 years ago

sinall commented 5 years ago

The model uses string value, not int or bool.

Here's the sample code: http://jsfiddle.net/o0Lfh3bq/5/

When editing, the current model value is not selected. The issue is similar to #752

ckosloski commented 5 years ago

If you remove the track by it works correctly https://jsfiddle.net/ckosloski/kby2839c/4/

sinall commented 5 years ago

OK, do you want to rename the title?

ckosloski commented 5 years ago

Does removing the track by not work for you? The radiolist issue that was fixed, was fixed in xeditablebecause there was code in xeditable that was not correct. There really isn't any code in xedtiable for selects. Only code for placeholder and multiple select https://github.com/vitalets/angular-xeditable/blob/master/src/js/directives/select.js

It is just the angular select that ends up getting used.

sinall commented 5 years ago

Yes it works. It just doesn't work with track by. Angular could work with track by, but the model have to be entire object as in ng-options: http://jsfiddle.net/psaovgx2/8/ However, when you select status2 first time, it becomes blank. Seems that the model have to be exactly same as one of the object in ng-options.

I'm not sure if we can create a temporary object based on user.status and use it internally? Then it could behave the same as radiolist.

Another way is using ng-selected, but it only works on <option>. FYI: How to have a default option in Angular.js select box

ckosloski commented 5 years ago

Xeditable already makes a copy. I'm not seeing anything obvious on what to fix. I tried a few things and couldn't figure anything out. Feel free to open a PR if you can figure out a fix.