在HTML中进行数据绑定后,如何解析kendovalidator未定义? [英] How to resolve kendovalidator is undefined in after data bind in HTML?

查看:164
本文介绍了在HTML中进行数据绑定后,如何解析kendovalidator未定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

file1.cshtml



file1.cshtml

<pre><form id="cust" name="Customer" method="post">
    <div>
        <p>@Html.TextBoxFor(m => m.Email, new { required = "required", placeholder = "Email", id = "cust-email", maxlength = 255 })</p>
        <label id="lbl-cust-email-error" class="error error-label-style">@Html.ValidationMessageFor(m => m.Email)</label>
        <small class="field-tip">Use your real email address. We don't spam.</small>
    </div>
<div>
            <input id="submit-cust" type="submit" value="Join"/>
        </div></form>







file2.cshtml






file2.cshtml

<pre><div id="Customeridentity" hidden="hidden" class="registration_form_element">
                                    @Html.Partial("_file1")
                                </div>
 <script>
$("body").on("click", "#submit-cust", function () {
var formValidator = $("form#cust").data('kendoValidator');
if(formValidator.validate()){
$.ajax({
                            type: 'POST',
                            url: '@Url.Action("IsCustomerModelStateValid", "Account")',
                            data: form.serialize(),
                            success: function (data) {
                                isClickedJoinFreightRover = false;
                                if (data.IsValid) {
                                    $(".field-validation-error").hide();
                                    var registerUrl = '@Url.Action("RegisterCustomer", "Account")',
                                }
                                else {
                                    $('#Customeridentity').html(data);
}
}
});
}
});
</script>





首次点击错误数据时,kendo验证工具正常运行。

$('#Customeridentity')。html(data)追加,然后再次提交kendo验证器未定义错误显示。数据来自同一形式且有错误价值。



我尝试了什么:



我差点尝试过所有可能性



first time click with wrong data kendo validator is working.
After $('#Customeridentity').html(data) append and next again submit the kendo validator is undefined error show.The data is coming same form and with error value.

What I have tried:

I have tried almost all possibility

推荐答案

body)。on( 点击 #submit-cust function (){
var formValidator =
("body").on("click", "#submit-cust", function () { var formValidator =


form#cust)。data(' kendoValidator');
if (formValidator.validate()){
("form#cust").data('kendoValidator'); if(formValidator.validate()){


.ajax({
type:' POST'
url:' @ Url.Action(IsCustomerModelStateValid,Account)'
data:form.serialize(),
成功: function (data){
isClickedJoinFreightRover = false ;
if (data.IsValid){
.ajax({ type: 'POST', url: '@Url.Action("IsCustomerModelStateValid", "Account")', data: form.serialize(), success: function (data) { isClickedJoinFreightRover = false; if (data.IsValid) {


这篇关于在HTML中进行数据绑定后,如何解析kendovalidator未定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆