// subscribe to swithChange event
// - show inputfield and warningbox when toggle is set "on"
// - hide inputfield and warningbox when toggle is set "off"
gj.event.subscribe('switchChange', function(val) {
if(val.id === 'switchWithInputdemo') {
$('#switchWithInputdemo_input').css('display', val.state ? 'block' : 'none' );
$('#switchWithInputdemo_postField').css('display', val.state ? 'block' : 'none' );
if(val.state){
gjl.warningbox.open('switchInputWarningbox');
}else {
gjl.warningbox.close('switchInputWarningbox');
}
}
});
// initialize the formline
gjl.formline.init($('#vdomSelect'), {
'id': 'vdomSelect',
'label': 'Label vdom select',
'fields': [{
'fieldtype': 'vnode',
'fieldID': 'vdomSelect_select',
'vnodeFunc': gj.vdom.createFormlineConfig(function () {
return gj.vdom.createSelect({
'id': 'vdomSelect_select',
'gj-store-key': 'testData.selected'
}, gj.store.getSelectArray('testData.selectValues'), gj.store.get('testData.selected'));
})
}]
});
// store that the example runs with
gj.store.setData({
'testData': {
'selectValues': {
'0': 'velg',
'1': 'Meat',
'2': 'Fish',
'3': 'Fruit'
},
'selected': '2'
}
});