-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewModel.js
59 lines (50 loc) · 1.93 KB
/
viewModel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
define(
['ojs/ojcore', 'knockout', 'jquery','ojs/ojinputtext', 'ojs/ojlabel','ojs/ojbutton'], function (oj, ko, $) {
'use strict';
function formBuilderComponentModel(context) {
var self = this;
self.composite = context.element;
self.inputvalues = ko.observable([]);
self.title = ko.observable();
self.callback = "";
self.uniqueID = ko.observable(Math.random().toFixed(2)*100);
self.handleClick = function(evt, ui){
//alert(evt)
var formData = {};
$("#"+self.uniqueID().toString()).find(".myInputs").each((i, inPut)=>{
console.log("found one == "+ inPut)
if(inPut.value != ''){
formData[inPut.id] = inPut.value;
}
})
if(typeof self.callback == "function"){
self.callback(formData)
}
}
context.props.then(function (propertyMap) {
//Store a reference to the properties for any later use
self.properties = propertyMap;
// console.log(self.properties)
//Parse your component properties here
if(self.properties.inputvalues){
self.inputvalues(self.properties.inputvalues)
}
if(self.properties.title){
self.title(self.properties.title)
}
if(self.properties.callback){
self.callback = self.properties.callback;
}
});
};
//Lifecycle methods - uncomment and implement if necessary
//ExampleComponentModel.prototype.activated = function(context){
//};
formBuilderComponentModel.prototype.attached = function(context){
};
//ExampleComponentModel.prototype.bindingsApplied = function(context){
//};
//ExampleComponentModel.prototype.detached = function(context){
//};
return formBuilderComponentModel;
});