【发布时间】:2026-01-18 05:25:01
【问题描述】:
我在 Pyramid 中有这个 delete 视图,我正在使用 mako 模板和 knockout js .
config.add_route('delete', '/delete/{id}')
这是我在金字塔中查看delete 的路线。我想将模板中的一些按钮绑定到这个 url,以便它调用 delete 视图。
我试过这样做:
<script>
this.delete = function(detail){
$.post(
"${request.route_url('delete', id=detail['id'])}",
{'action' : 'delete', 'id' : detail.id()},
function(response){
//remove the currently selected detail from the array
self.details.remove(detail);
}
);
};
但是,这会返回以下 traceback:
TypeError: 'Undefined' object has no attribute '__getitem__'
- 这样做的正确方法是什么?
-
delete视图将location设置为当前页面。那么有没有办法在不刷新当前页面的情况下做到这一点?
【问题讨论】:
标签: javascript python knockout.js pyramid mako