Commit f0d8d3a0 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Added new events to Form: `form.validation.(before|after)`

parent abbb3bb0
...@@ -116,12 +116,17 @@ var QfqNS = QfqNS || {}; ...@@ -116,12 +116,17 @@ var QfqNS = QfqNS || {};
* @returns {*} * @returns {*}
*/ */
n.Form.prototype.validate = function () { n.Form.prototype.validate = function () {
this.eventEmitter.emitEvent('form.validation.before', n.EventEmitter.makePayload(this, null));
// uncommented because bootstrap-validator sets novalidate="true" on form. // uncommented because bootstrap-validator sets novalidate="true" on form.
//if (this.$form.attr('novalidate')) { //if (this.$form.attr('novalidate')) {
// return true; // return true;
//} //}
return document.forms[this.formId].checkValidity(); var result = document.forms[this.formId].checkValidity();
this.eventEmitter.emitEvent('form.validation.after', n.EventEmitter.makePayload(this, {validationResult: result}));
return result;
}; };
/** /**
......
...@@ -90,6 +90,7 @@ var QfqNS = QfqNS || {}; ...@@ -90,6 +90,7 @@ var QfqNS = QfqNS || {};
//n.Helper.jqxEditor(); //n.Helper.jqxEditor();
n.Helper.tinyMce(); n.Helper.tinyMce();
this.form.on('form.submit.before', n.Helper.tinyMce.prepareSave); this.form.on('form.submit.before', n.Helper.tinyMce.prepareSave);
this.form.on('form.validation.before', n.Helper.tinyMce.prepareSave);
}; };
n.QfqForm.prototype.on = n.EventEmitter.onMixin; n.QfqForm.prototype.on = n.EventEmitter.onMixin;
......
...@@ -343,8 +343,8 @@ ...@@ -343,8 +343,8 @@
<label for="notes-editor" class="control-label">Notes</label> <label for="notes-editor" class="control-label">Notes</label>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<textarea id="notes-editor" class="jqw-editor" <textarea id="notes-editor" class="qfq-tinymce"
data-control-name="notesField" name="notesField"> data-control-name="notesField" name="notesField" required>
</textarea> </textarea>
</div> </div>
...@@ -836,7 +836,7 @@ ...@@ -836,7 +836,7 @@
</div> </div>
</form> </form>
<a href="www.google.ch">away</a> <a href="https://www.google.ch">away</a>
</div> </div>
<script type="application/jqw-combobox-source" id="combobox1_source"> <script type="application/jqw-combobox-source" id="combobox1_source">
...@@ -853,6 +853,7 @@ ...@@ -853,6 +853,7 @@
<script src="../js/validator.min.js"></script> <script src="../js/validator.min.js"></script>
<script src="../js/jqx-all.js"></script> <script src="../js/jqx-all.js"></script>
<script src="../js/globalize.js"></script> <script src="../js/globalize.js"></script>
<script src="../js/tinymce.min.js"></script>
<script src="../js/EventEmitter.min.js"></script> <script src="../js/EventEmitter.min.js"></script>
<script src="../js/qfq.debug.js"></script> <script src="../js/qfq.debug.js"></script>
......
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