-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi Guys, The following piece of code is part of a grid . so it throws duplicate id exception for the second row.
<textbox hflex="1" value="@load(each.piecePartRegVO.partChineseSpecification) @bind(each.piecePartRegVO.partChineseSpecification)" onChanging="fgid_chinese_spec.value = event.value"/>
<textbox hflex="1" id="fgid_chinese_spec" value="@load(each.piecePartRegVO.fgidChineseSpecification) @save(each.piecePartRegVO.fgidChineseSpecification, before={'save', 'confirm'})"/>
is there any way i can generate dynamic id(fgidchinesespec) and assign it to onchange event.
Thanks Pratik
If you are working with MVVM you don't need to use the id attribute.
Let me explain what causes this issue :
You make use of <template> and inside the template you have that code.
First row creates 2 textboxes, one without id and one with id "fgid_Chinese_spec"
Now you are making a second row, again 2 textboxes and one without id and again one with id "fgid_Chinese_spec".
Because you are still in the same spaceowner you can't use that id twice.
So easiest solution is to remove id, or add to the id the index of the forEachStatus to it, like this it also stay's unique.
id="fgid_Chinese_spec${forEachStatus.index}"
@bind
stands for @load
+ @save
so please use it correct. You are now loading the value twice.
your onChanging
event will never happen as long you don't set instant="true".
This is done by default because otherwise you have a very chatty application. They update the value with the onChange
event for improve performance.
But you can allow to update the value in the onChanging
by just setting instant="true"
in your textbox.
Like this you can remove the onChanging command also.
Your solution is actually pretty simple :
<div form="@id('fx') @load(each.piecePartRegVO) @save(each.piecePartRegVO, before={'save', 'confirm'})">
<label hflex="1" value="@load(each.piecePartRegVO.partChineseSpecification)"/>
<textbox hflex="1" value="@load(fx.fgidChineseSpecification) @save(fx.fgidChineseSpecification)"/>
</div>
Like this your label has the original value => the textbox can change but will not be persisted if you don't execute one of the 2 commands.
Greetz chill.
Asked: 2016-02-09 10:24:18 +0800
Seen: 17 times
Last updated: Feb 09 '16
@chillworld : how to "add to the id the index of the" could you please help with this?
PRATIKKAR ( 2016-02-09 11:11:51 +0800 )edit@chillworld: i updated as follows but still not working :
<textbox hflex="1" value="@load(each.piecePartRegVO.partChineseSpecification) @bind(each.piecePartRegVO.partChineseSpecification)" onChanging="fgidChinesespec${forEachStatus.index}.value = event.value"/>
PRATIKKAR ( 2016-02-09 12:07:31 +0800 )edit