inputError v JS vracia null
- steelbull
- Člen | 241
Mam formular, ktory v latte manualne vykreslujem. Je to velky formular, preto tu ani zdrojaky nevkladam. Ma niekolko submit buttonov, vsetko funguje OK, ale:
Za niektorych okolnosti pred ulozenim formular zobrazi modal window. Moj modal window generujem javascriptom. Jeho obsah nastavujem v property content, kde som vlozil formularove prvky:
{* Modal Window pre zruseniu projektu *}
{ifset $form['btn_cancel']}
{input 'btn_cancel'}
<div id="cancelDialog"></div>
<script>
$(function () {
"use strict";
$(document).ready(function () {
var cancelDialog = $("#cancelDialog");
var cancelDialogShow = $("#cancelDialogShow");
cancelDialog.kendoDialog({
width: "400px",
title: {_project.form.dialog_title_cancel},
closable: false,
modal: true,
visible: false,
content: `
<div class="k-form">
{label 'reason_cancelled_id'}<br/>
{input 'reason_cancelled_id'}<br/>
<span id="err_reason_cancelled_id" class="form-error-message">{inputError 'reason_cancelled_id'}</span><br/>
{label 'reason_cancelled_desc'}<br/>
{input 'reason_cancelled_desc'}<br/>
<span id="reason_cancelled_desc" class="form-error-message">{inputError 'reason_cancelled_desc'}</span>
</div>`,
actions: [
{ text: {_cp.close}},
{
text: {_cp.cancel}, primary: true, action: function () {
var reason = $("select[name=reason_cancelled_id]").val().trim();
var canSubmit = true;
if (!reason) {
canSubmit = false;
$('#err_reason_cancelled_id').text({_form.validator.required});
} else {
$('#err_reason_cancelled_id').text('');
}
if (canSubmit) {
alert('sss');
}
return false;
}
}
]
});
cancelDialogShow.click(function () {
cancelDialog.data("kendoDialog").open();
});
});
});
</script>
{/ifset}
Problem je, ze na kazdom mieste, kde pouzijem {inputError …} a inputError neobsahuje ziadnu chybovu hlasku sa zobrazi null a nie prazdny retazec. Ako mozem docielit, aby sa tam to null nezobrazovalo?
Dakujem.
Editoval steelbull (20. 4. 2018 19:31)