[SOLVED] Set property to null / undefined with nested property bound to input

Hi all,

referring to the following gist I need to click “removeInput2” twice to get the object set to undefined (Gist Run).

Am I doing something wrong or is this a bug?

It is related to Aurelia behavior of accessing member of an object. Relevant github issue here https://github.com/aurelia/binding/issues/205

The issue comes from the combination of value.bind="myobject.input2" and the assignment: myobject = undefined.

can you give me an advise how to solve that?

Can you use a boolean property instead of myobject to toggle off the div?

yes of course I can find a way how to toggle the visibility.
The problem is, that on save the “empty” object also gets send to the webservice that I don’t want to. It should be undefined.
Do you know what I mean?

Yes of course I could go into the save method and set the object to undefined manually. But this would be a dirty workaround (in my opinion).

Updated Gist (edited save-button): https://gist.run/?id=425993b04a977466fa685758389aa2b4

I’m aware of this issue but I haven’t found any solution yet beside this workaround https://gist.run/?id=a1d401603bac88a00e7a261a71d42a30

Basically we want to instruct Aurelia undefined is the same value with empty string, do not attempt a write back.

1 Like

Great. Many thanks. I love this workaround. Ways better than my ones

1 Like