Skip to content
Snippets Groups Projects
Commit 0cbc4c82 authored by bbaer's avatar bbaer
Browse files

added hidden input, fixed submit

parent b60d5d17
No related branches found
No related tags found
No related merge requests found
Pipeline #780 passed
......@@ -64,7 +64,9 @@ var QfqNS = QfqNS || {};
}
if (this.type === "row") $element = this._buildRow();
if (this.type === "checkbox") $element = this._buildInput();
if (this.type === "checkbox" ||
this.type === "radio" ||
this.type === "hidden") $element = this._buildInput();
if (this.type === "label") $element = this._buildLabel();
if (this.children) {
......@@ -87,7 +89,11 @@ var QfqNS = QfqNS || {};
};
n.ElementBuilder.prototype._buildInput = function() {
var $block = this._buildBlock(this.width);
var $block = {};
if (this.type !== "hidden") {
$block = this._buildBlock(this.width);
}
var options = {
class: this._getOption(this.class),
type: this._getOption(this.type),
......@@ -108,8 +114,13 @@ var QfqNS = QfqNS || {};
that.submit();
});
}
$block.append($input);
return $block;
if (this.type !== "hidden") {
$block.append($input);
return $block;
} else {
return $input;
}
};
n.ElementBuilder.prototype._buildLabel = function() {
......@@ -156,28 +167,20 @@ var QfqNS = QfqNS || {};
};
n.ElementBuilder.prototype.handleSubmit = function() {
console.log("Submit pressed");
console.log(this.$element.serialize());
var data = this.$element.serialize();
var that = this;
$.ajax({
url: this.submitTo,
type: "POST",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
success: function(msg) {
that.submitSuccess(msg);
}
});
$.post(this.submitTo, this.$element.serialize())
.done(this.submitSuccessHandler.bind(this))
.fail(this.submitFailureHandler.bind(this));
};
n.ElementBuilder.prototype.submitSuccess = function(msg) {
var configuration = msg['element-update'];
n.ElementBuilder.prototype.submitSuccessHandler = function(data, textStatus, jqXHR) {
var configuration = data['element-update'];
n.ElementUpdate.updateAll(configuration);
this.eventEmitter.emitEvent('form.submit.success',
n.EventEmitter.makePayload(this, "submit"));
};
n.ElementBuilder.prototype.submitFailureHandler = function (data, textStatus, jqXHR) {
console.error("Submit failed");
};
})(QfqNS);
......@@ -5,6 +5,11 @@
"class": "",
"submitTo": "api/droplet_submit_success.json",
"children": [
{
"type": "hidden",
"name": "sip",
"value": "55xewf2334"
},
{
"type": "row",
"class": "",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment