forked from minikomi/Bootstrap-Form-Builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
75 lines (72 loc) · 2.68 KB
/
app.js
File metadata and controls
75 lines (72 loc) · 2.68 KB
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
68
69
70
71
72
73
74
75
define([
"jquery", "underscore", "backbone"
, "collections/snippets", "collections/my-form-snippets"
, "views/tab", "views/my-form"
, "text!data/input.json", "text!data/radio.json", "text!data/select.json", "text!data/buttons.json"
, "text!templates/app/render.html", "text!templates/app/about.html", "text!templates/app/renderjson.html",
], function(
$, _, Backbone
, SnippetsCollection, MyFormSnippetsCollection
, TabView, MyFormView
, inputJSON, radioJSON, selectJSON, buttonsJSON
, renderTab, aboutTab, jsonTab
) {
return {
initialize: function() {
//Bootstrap tabs from json.
new TabView({
title: "Input"
, collection: new SnippetsCollection(JSON.parse(inputJSON))
});
new TabView({
title: "Radios / Checkboxes"
, collection: new SnippetsCollection(JSON.parse(radioJSON))
});
new TabView({
title: "Select"
, collection: new SnippetsCollection(JSON.parse(selectJSON))
});
new TabView({
title: "Buttons"
, collection: new SnippetsCollection(JSON.parse(buttonsJSON))
});
new TabView({
title: "Rendered"
, content: renderTab
});
new TabView({
title: "JSON"
, content: jsonTab
});
/*new TabView({
title: "About"
, content: aboutTab
});*/
//Make the first tab active!
$("#components .tab-pane").first().addClass("active");
$("#formtabs li").first().addClass("active");
// Bootstrap "My Form" with 'Form Name' snippet.
var formView = new MyFormView({
title: "Original"
, collection: new MyFormSnippetsCollection([
{"title": "Form Name"
, "fields": {
"name": {
"label": "Form Name"
, "type": "input"
, "value": "Form Name"
}
}
}
])
});
$('#loadJSON').on('click', function() {
event.preventDefault();
var value = $("#jsonrender").val();
var json = $.parseJSON(value);
formView.collection = new MyFormSnippetsCollection(json);
formView.initialize();
});
}
}
});