gpt4 book ai didi

javascript - 如何进行 django 就地编辑以及基于 AJAX 的 django 无尽分页

转载 作者:行者123 更新时间:2023-11-28 08:22:33 24 4
gpt4 key购买 nike

基于 AJAX 的 django 无休止分页有 2 个模板:1.主要issue_detail.html2.分页模板issue_detail_page.html

在 base.html 模板中,在 extra_header block 之前,我有:

{% inplace_static %}

我尝试在 issues_detail_page.html 中执行以下操作:

{% load endless %}
{% load inplace_edit %}

{% lazy_paginate 2 completed_actions using "completed_actions_page" %}
{% for action in completed_actions %}
<tr>
<td><a href="{% url 'action_detail' issuelist.id issue.id action.id %}">{{action.title}}</a></td>
<td>{% inplace_edit "action.owner" %}</td>
<td>{% inplace_edit "action.event_date" %}</td>
<td>{% inplace_edit "action.state" %}</td>
</tr>
{% endfor %}
{% show_more %}

但是 Ajax 加载的页面(表数据)不可编辑。

我检查了HTML,发现第一个/原始表数据是:

<span class="inplaceedit textinplaceedit enable">

而通过单击“更多”链接使用 AJAX 加载的页面稍后表数据是:

<span class="inplaceedit textinplaceedit">

有人可以建议如何实现这项工作吗?

最佳答案

试试这个:

$.getScript("{{ STATIC_URL }}js/jquery.json.js").done(function( script, textStatus ) {
$.getScript("{{ STATIC_URL }}js/jquery.inplaceeditform.js").done(function( script, textStatus ) {
var options = {"getFieldUrl": "/inplaceeditform/get_field/",
"saveURL": "/inplaceeditform/save/",
"successText": "Successfully saved",
"eventInplaceEdit": "click",
"disableClick": true,
"autoSave": true,
"unsavedChanges": "You have unsaved changes!",
"enableClass": "enable",
"fieldTypes": "input, select, textarea",
"focusWhenEditing": true};
var inplaceManager = $(".inplaceedit:not(.enable)").inplaceeditform(options);
inplaceManager.enable();
});
});

关于javascript - 如何进行 django 就地编辑以及基于 AJAX 的 django 无尽分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22797312/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com