简体   繁体   English

Ajax调用返回带有Kendo datepicker的Partial View的刷新不正确

[英]Ajax call returning Partial View with Kendo datepicker not refreshing properly

I am adding to a list of elements through an ajax call. 我通过ajax调用添加到元素列表。 The ajax call sends information to controller, controller adds everything to database, then grabs all the items for the list from the database, adds the items to a view model, then returns a partial view with the model. Ajax调用将信息发送到控制器,控制器将所有内容添加到数据库,然后从数据库中获取列表的所有项目,将这些项目添加到视图模型,然后返回该模型的部分视图。 I clear the div container for the list then add the returning HTML. 我清除列表的div容器,然后添加返回的HTML。

$('#container').empty().html(result);

My problem is, in the HTML, I have Kendo Datepickers. 我的问题是,在HTML中,我有Kendo Datepickers。 The page loads fine, and if I do a refresh everything is fine. 页面加载正常,如果刷新,一切正常。 But right after the Ajax call, the Kendo Datepickers are not there. 但是在Ajax通话之后,Kendo Datepickers不在那儿。 I debugged and got the result HTML from the ajax call and the following is what is showing for the datepickers: 我调试并从ajax调用中得到了结果HTML,以下是datepickers显示的内容:

jQuery(function(){jQuery("#dueDate0").kendoDatePicker({"format":"M/d/yyyy","min":new Date(1900,0,1,0,0,0,0),"max":new Date(2099,11,31,0,0,0,0)});});

the 'dueDate0' is obviously the ID of the element, but it should not be zero it should be an actual ID number ( ex. 12 ). “ dueDate0”显然是元素的ID,但不应为零,而应为实际的ID号(例如12)。 When I look at the HTML after the AJAX call, the datepickers are just input elements with a date type. 当我在AJAX调用之后查看HTML时,日期选择器只是具有日期类型的输入元素。

Any suggestions on what to do? 有什么建议吗?

Thanks 谢谢

EDIT: Here is the HTML that gets return in the AJAX call. 编辑:这是在AJAX调用中返回的HTML。

<div id="accordion">
    <div class="ItemList">
        <table class="tblPriorityElement">
            <tr>
                <td class="tdPrioritySelect">
                    <div class='handle'><span class='ui-icon ui-icon-carat-2-n-s'></span></div>
                </td>
                <td class="tdPriorityName">fasdfasr4</td>
                <td class="tblType" tabindex="0">
                    <span class="txtType">Project</span>
                </td>
                <td class="tdPriorityDate" tabindex="0">
                    <time>10/8/2013</time>
                </td>
                <td class="tdAllocation" tabindex="0">
                    <span class="txtAllocation">0 hrs</span>
                </td>
                <td class="tdDeletePriority">;
                    <a href="#"><img src="../../Images/redx.png"/></a>
                </td>
            </tr>
        </table>
        <div class="content">
            <form class="editItem">
                <input id="ItemID" name="ItemID" type="hidden" value="0" />
                <label>Name:</label>
                <input class="text-box single-line" id="Item_Name" name="Item.Name" type="text" value="fasdfasr4" />
                <label>Type:</label>
                <input class="text-box single-line" id="Item_Type" name="Item.Type" type="text" value="Project" />
                <label>Due date:</label>
                <input class="k-input" id="dueDate0" name="dueDate0" type="date" value="10/8/2013" />
jQuery(function(){jQuery("#dueDate0").kendoDatePicker({"format":"M/d/yyyy","min":new Date(1900,0,1,0,0,0,0),"max":new Date(2099,11,31,0,0,0,0)});});

                <br/>
                <label>End Date:</label>
                <input class="k-input" id="endDate0" name="endDate0" type="date" />
jQuery(function(){jQuery("#endDate0").kendoDatePicker({"format":"M/d/yyyy","min":new Date(1900,0,1,0,0,0,0),"max":new Date(2099,11,31,0,0,0,0)});});

                    <label>Start Date:</label>
                    <input class="k-input" id="startDate0" name="startDate0" type="date" value="10/8/2013" />
jQuery(function(){jQuery("#startDate0").kendoDatePicker({"format":"M/d/yyyy","min":new Date(1900,0,1,0,0,0,0),"max":new Date(2099,11,31,0,0,0,0)});});

                <br/>
                <input type="submit" value="save"/>
            </form>

        </div>
    </div>
</div>

When generating the partial view,just define some kind of random id for the datepicker - for example Guid.NewGuid() or something. 生成局部视图时,只需为日期选择器定义某种随机id-例如Guid.NewGuid()或其他内容。 are you using the MVC helpers to define the datepicker? 您是否在使用MVC助手来定义日期选择器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM