define([
    "text!src/templates/form.html"
], function(templateForm) {
    var hr = codebox.require("hr/hr");
    var commands = codebox.require("core/commands");
    var FormView = codebox.require("views/form");

    var Tab = codebox.tabs.Panel.extend({
        className: "component-settings",
        template: templateForm,
        events: {
            "click .do-submit": "onSubmit",
            "click .do-open-json": "onOpenJson"
        },

        initialize: function() {
            Tab.__super__.initialize.apply(this, arguments);

            this.form = new FormView({
                schema: codebox.settings.toSchema(),
                values: codebox.settings.exportJson()
            });
        },

        render: function() {
            this.form.detach();
            this.form.update();

            return Tab.__super__.render.apply(this, arguments);
        },

        finish: function() {
            this.form.$el.appendTo(this.$(".form-content"));

            return Tab.__super__.finish.apply(this, arguments);
        },

        // Submit form
        onSubmit: function(e) {
            if (e) e.preventDefault();

            var data = this.form.getValues();
            console.log("submit", data);
            codebox.settings.importJSON(data);
        },

        // Open as json
        onOpenJson: function(e) {
            if (e) e.preventDefault();

            return commands.run("file.open", {
                file: codebox.settings.getFile()
            });
        }
    });

    return Tab;
});
@@ -61,24 +61,65 @@
 lateForm) %7B%0A
+    var _ = codebox.require(%22hr/utils%22);%0A
     var hr =
@@ -141,24 +141,24 @@
 e(%22hr/hr%22);%0A
-
     var comm
@@ -734,32 +734,209 @@
 %0A            %7D);
+%0A%0A            this.listenTo(codebox.settings, %22change%22, function() %7B%0A                _.defer(this.form.setValues.bind(this.form), codebox.settings.exportJson());%0A            %7D);
 %0A        %7D,%0A%0A   
@@ -1356,32 +1356,32 @@
 ventDefault();%0A%0A
+
             var 
@@ -1414,49 +1414,8 @@
 ();%0A
-            console.log(%22submit%22, data);%0A
     

Update settings page when values changed