|
|
define([
|
|
|
"jquery",
|
|
|
"collections/snippets",
|
|
|
"collections/my-form-snippets",
|
|
|
"views/tab",
|
|
|
"views/my-form",
|
|
|
"text!data/input.js", "text!data/radio.js", "text!data/select.js", "text!data/button.js",
|
|
|
"text!templates/app/render.html", "text!templates/app/about.html",
|
|
|
], function (
|
|
|
$,
|
|
|
SnippetsCollection,
|
|
|
MyFormSnippetsCollection,
|
|
|
TabView,
|
|
|
MyFormView,
|
|
|
inputJSON, radioJSON, selectJSON, buttonJSON,
|
|
|
renderTab, aboutTab
|
|
|
) {
|
|
|
return {
|
|
|
initialize: function () {
|
|
|
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(buttonJSON)),
|
|
|
});
|
|
|
new TabView({
|
|
|
title: "Rendered",
|
|
|
content: renderTab
|
|
|
});
|
|
|
new TabView({
|
|
|
title: "About",
|
|
|
content: aboutTab
|
|
|
});
|
|
|
//Make the first tab active!
|
|
|
$("#components .tab-pane").first().addClass("active");
|
|
|
$("#formtabs li").first().addClass("active");
|
|
|
//读取数据库的json类型,转换为对象
|
|
|
var form_structure_json = $('#form_structure').val();
|
|
|
if (form_structure_json === '') {
|
|
|
form_structure_json = '{"clsname":"snippets","data":[{"title":"Form Name","fields":{"name":{"label":"Form Name","type":"input","value":"Form Name","name":"name"},"title":{"label":"Form Title","type":"input","value":"Form Title"},"smalltitle":{"label":"Form Small Title","type":"input","value":"Form Small Title"}}}],"$el":{"0":{"jQuery183027588080591522157":72},"length":1}}';
|
|
|
}
|
|
|
form_structure_json = JSON.parse(form_structure_json);
|
|
|
//console.log(form_structure_json.data);
|
|
|
|
|
|
new MyFormView({
|
|
|
title: "Original",
|
|
|
collection: new MyFormSnippetsCollection(
|
|
|
form_structure_json.data
|
|
|
)
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}); |