-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsampleUsage.js
executable file
·67 lines (53 loc) · 1.26 KB
/
sampleUsage.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
60
61
62
63
64
65
66
67
$(function(){
$( "#tabs" ).tabs({ modal: true });
//################Dialog Box's#################################
$( "#dialog-form" ).dialog({
autoOpen: true,
height: 300,
width: 350,
modal: true
});
var criaObj = function(a, b, c){
return {
nome:ko.observable(a),
nPessoas:ko.observable(b),
id:ko.observable(c),
updateObj:function(novoNome){
//TODO:ServerSide Stuff
this.nome(novoNome);
}
};
}
var myModel =
{
quartos: ko.observableArray
([
new criaObj('teste1',1,1),
new criaObj('teste2',2,2),
new criaObj('teste3',7,3),
new criaObj('teste4',5,4),
new criaObj('teste5',2,5),
new criaObj('teste6',3,6)
]),
addNewObj: function(obj){
//TODO:ServerSide Stuff
var newObj = criaObj(obj.nome, obj.nPessoas, obj.id);
myModel.quartos.push(newObj);
}
};
myModel.gridViewModel = new ko.simpleGrid.viewModel({
data: myModel.quartos,
functionAddNewObj: myModel.addNewObj,
columns:
[
{ headerText: "Nome", rowText: "nome" },
{ headerText: "Numero Maximo pessoas", rowText: "nPessoas" }
],
pageSize: 3,
editarClick: function(objClicked){
objClicked.mudaNome('novoNome');
},
mostraEditar: true
});
ko.applyBindings(myModel);
});