vitalets / angular-xeditable

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

How to change display value when editing form? #767

Closed sinall closed 4 years ago

sinall commented 4 years ago

I have a dropdown and a text input, when editing, I want to change the text of the input if dropdown is changed.

[some text] => I want to change view value of this input [dropdown] => if a new option is selected

I tried to set editableForm['name of input']['$viewValue'] or set editableForm.$data['name of input'], but didn't work.

Here's the demo.

ckosloski commented 4 years ago

Maybe this previous issue with help #521

sinall commented 4 years ago

@ckosloski The user case is different. In my case, I want to change the display value, regardless it is triggered by dropdown or a button. I don't want to save the display valueto model until user click the save button.

The real case is like this: [0 0/1 9 * or 2020-05-29 09:40:00] => I want to change view value of this input [CRON or FIXED_TIME] => if a new option is selected I use single input field to save the expression which could be a CRON expression or a DATA TIME expression. So it will have very different formats according to its type.

For example: [2020-05-29 09:40:00] => change display value to empty [FIXED_TIME] => if option is changed to CRON In this case, I want only the view value get changed, if will be saved to model if save is clicked or will be discard if cancel is clicked.

I guess I could use jQuery to change the input value, but I don't what will happen, and I don't know if angular-xeditable have such API to achieve this.

ckosloski commented 4 years ago

Try this demo Change the group drop down and the user name changes.

sinall commented 4 years ago

@ckosloski Demo It can‘t be saved into model when save is clicked. So the view-model binding is broken. Somehow this method is different from user manually change.

ckosloski commented 4 years ago

Are you referring to the error message Username should be `awesome` or `error? That was in the original demo link you posted.

sinall commented 4 years ago

Are you referring to the error message Username should be `awesome` or `error? That was in the original demo link you posted.

No, I changed the link several times, it should be this demo.

ckosloski commented 4 years ago

This seems to work

sinall commented 4 years ago

@ckosloski Thanks you, it works!