Foros

Inicio » Alloy UI » English

Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
Andrej Litowka
Keydown event
14 de noviembre de 2012 2:45
Respuesta

Andrej Litowka

Ranking: Junior Member

Mensajes: 79

Fecha de incorporación: 30 de junio de 2010

Mensajes recientes

Hi All!

I have following code

 1
 2<aui:form>
 3<aui:input name="Field 1" id="val1"></aui:input>
 4<aui:input name="Field 2" id="val2"></aui:input>
 5<aui:input name="Result" id="val3"></aui:input>
 6</aui:form>
 7
 8<aui:script use="aui-base, node">
 9var v = A.on('keydown', function(event) {
10var v1 = A.one('#<portlet:namespace/>val1').get('value');
11var v2 = A.one('#<portlet:namespace/>val2').get('value');
12
13var result = A.one('#<portlet:namespace/>val3');
14result.set('value', v1 + v2);
15}
16);
17</aui:script>


The Idea is, that sum of values in Field 1 and 2 should be shown in the Result filed. So if I enter e.g. 1 in the Field 1 nothing happens. If I continue enter and put 2 (so now it's 12) ind the Field 1 the value 1 appears in the Result. And so on. If 3 was entered 12 appears in the Result. What I expected is, when I enter 1, it immediately appears in the result. Then when I enter 2 it also immediatelly appears in the Result.

What is wrong with the script?

Thanks and regards,
Andrej

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!