Commit 3215f068 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files
parent 5a4b737c
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
/* global $ */
/**
* Qfq Namespace
*
* @namespace QfqNS
*/
var QfqNS = QfqNS || {};
/**
* Qfq Helper Namespace
*
* @namespace QfqNS.Helper
*/
QfqNS.Helper = QfqNS.Helper || {};
(function (n) {
'use strict';
var jqxComboBox = function () {
var index;
var $containers = $("div.jqw-combobox");
$containers.each(function (index, object) {
(function ($container) {
var controlName = $container.data('control-name');
if (!controlName) {
QfqNS.Log.error("jqwComboBox container does not have a 'data-control-name' attribute.");
return;
}
var sourceId = controlName + "_source";
var $sourceScript = $('#' + sourceId);
if ($sourceScript.length !== 1) {
QfqNS.Log.error("Unable to find data for jqwComboBox using id '" + sourceId + "'");
return;
}
var source = JSON.parse($sourceScript.text());
$container.jqxComboBox({source: source});
var $hiddenInput = $("<input>")
.attr('type', 'hidden')
.attr('name', controlName);
$container.after($hiddenInput);
$hiddenInput.val($container.jqxComboBox('val'));
$container.on('change', function (event) {
$hiddenInput.val(event.args.item.value);
});
})($(object));
});
};
n.jqxComboBox = jqxComboBox;
})(QfqNS.Helper);
\ No newline at end of file
......@@ -77,6 +77,8 @@ var QfqNS = QfqNS || {};
// Initialize jqxDateTimeInput elements.
n.Helper.jqxDateTimeInput();
// Initialize jqxComboBox elements.
n.Helper.jqxComboBox();
};
n.QfqForm.prototype.on = n.EventEmitter.onMixin;
......
......@@ -244,6 +244,18 @@
</div>
<div class="form-group">
<div class="col-md-2">
<label for="combobox1" class="control-label">Combobox 1</label>
</div>
<div class="col-md-6">
<div id="combobox1" class="jqw-combobox"
data-control-name="combobox1"></div>
</div>
</div>
</div>
......@@ -811,6 +823,15 @@
<a href="www.google.ch">away</a>
</div>
<script type="application/jqw-combobox-source" id="combobox1_source">
[
"item 1",
"item 2",
"item 3"
]
</script>
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/validator.min.js"></script>
......@@ -1042,8 +1063,6 @@
fileDeleteUrl: 'api/' + $("#fileDeleteUrl").val(),
});
QfqNS.Helper.jqxDateTimeInput();
$("#submitTo").on("change", function (evt) {
qfqPage.settings.submitTo = 'api/' + $(evt.target).val();
qfqPage.qfqForm.submitTo = 'api/' + $(evt.target).val();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment