|
1 | var field = new inputEx.SerializeField({ |
2 | parentEl: 'container2', |
3 | label: 'Your name', |
4 | description: 'Please enter your name', |
5 | |
6 | serializer: 'xml', |
7 | |
8 | subfield: { |
9 | type: 'group', |
10 | fields: [ |
11 | { |
12 | type: 'group', |
13 | name: 'person', |
14 | fields: [ |
15 | { name: 'firstname', typeInvite: 'firstname' }, |
16 | { name: 'lastname', typeInvite: 'lastname' } |
17 | ] |
18 | } |
19 | ] |
20 | } |
21 | |
22 | }); |
23 | |
24 | var el = YAHOO.util.Dom.get('container2'); |
25 | |
26 | var button2 = inputEx.cn('button', null, null, "SetValue"); |
27 | el.appendChild(button2); |
28 | YAHOO.util.Event.addListener(button2, "click" ,function() { |
29 | var xml = String.fromCharCode(60)+'?xml version="1.0" encoding="UTF-8" ?'+String.fromCharCode(62)+String.fromCharCode(60)+'person'+String.fromCharCode(62)+String.fromCharCode(60)+'firstname'+String.fromCharCode(62)+'Jimi'+String.fromCharCode(60)+'/firstname'+String.fromCharCode(62)+String.fromCharCode(60)+'lastname'+String.fromCharCode(62)+'Hendrix'+String.fromCharCode(60)+'/lastname'+String.fromCharCode(62)+String.fromCharCode(60)+'/person'+String.fromCharCode(62); |
30 | field.setValue(xml); |
31 | }); |
32 | |
33 | var logDiv = inputEx.cn('div', null, null, "Log :"); |
34 | el.appendChild(logDiv); |
35 | field.updatedEvt.subscribe(function(e,params) { |
36 | var value = params[0].replace( new RegExp(String.fromCharCode(60),"g") , '<' ).replace( new RegExp(String.fromCharCode(62),"g") , '>' ); |
37 | logDiv.innerHTML += "Updated at "+(new Date())+" with value "+inputEx.htmlEntities(value); |
38 | logDiv.appendChild(inputEx.cn('br')); |
39 | }); |