html - django 模板和 Jquery 中未定义的 data-traget 属性
问题描述
我正在尝试访问数据目标值,它正在工作,但随后意外停止,下面是我的 html"
<div class="loan-pending" id='loan-pending-{{loan.loan_id}}' data-target="loan-pending-data-{{loan.id}}" data-query-loan-id="loan={{loan.id}}">
{% trans 'Loan Applications' %}: {{loan.loan_id}}
</div>
然后,这是 jquery :
const loanPendingData = $(`#loan-pending-data-${loanID}`);
我也试过了,如下:
const loanPendingData = $(this).data('target');
完整的js脚本:
window.addEventListener("load", function () {
(function ($) {
"use strict";
$(document).ready(function () {
checkQueryParamsForPendingLoans();
function checkQueryParamsForPendingLoans() {
const loanPendingData = $(`#loan-pending-data-${loanID}`);
}
}
})(django.jQuery);
但没有运气,是什么导致 django 和 jquery 出现这种情况?
解决方案
推荐阅读
- c# - mongoexport/projection:仅导出不等于 null 的字段
- r - 如何将向量分成R中具有相同数量观察的组?
- postgresql - docker-compose.yml 中不健康的 postgres 容器
- kotlin - gRPC Java - 服务器收到请求后立即记录请求有效负载
- javascript - 为什么我无法使用 Selenium 找到此按钮并单击它?(它甚至没有出现在 .page_source 上)
- rest - 如何检索 Twitch API 不记名令牌
- mysql-workbench - 如何解决错误:“字段列表”中的未知列“delete_versioning_rows_priv”
- python - 如果数组是在 GPU 中定义的,为什么 np.einsum() 可以在 GPU 上运行?
- google-apis-explorer - 在 Cromebook 设备上运行 TryThis API 时,我无法获得超过 1000 个数据
- google-play-console - Google Play 控制台许可证测试不起作用