在 symfony 上工作,我正在使用 bootbox 开发以下 javascript 函数:
function ask_delete(id)
{
bootbox.confirm("Are you sure?", function(result) {
if(result)
{
document.location.href = "{{ path('SomethingBundle_delete', {'id': id}) }}";
}
});
}
我想捕获我的 id 参数并将其作为参数传递给我的“SomethingBundle_delete”路线。 然而 id 似乎没有定义。你知道我如何将它作为参数传递吗?
最佳答案
id
值可用,但您需要将其作为值而不是字符串文字引用
"{{ path('SomethingBundle_delete', {'id': " + id + "}) }}"
关于javascript - 尝试在函数中使用参数时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22077184/