我不确定自己在做什么错,但是我搜索了所有“将数据传递给引导程序模式”的帖子,但仍然找不到答案。
我与用户有一张桌子。每行中都有一个“删除用户按钮”。当您单击“删除”时,将显示一个模式,其中显示以下图例:“确定要删除吗?”
我希望用户名显示在该图例中,因此我将用户名发送到JS文件,但不显示。什么也没出现。
这是每一行中的删除按钮:
<td><a href="#" onclick="callToModal({$frontuser->username});return false;" class="btn mini red-stripe" role="button" >Delete</a></td>
我正在使用smarty,这就是为什么参数看起来像这样的原因: {$frontuser->username}
在该代码上方,我具有模态的定义:
<!-- modal -->
<div id="myModal3" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel3" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h3 id="myModalLabel3"></h3>
</div>
<div class="modal-body">
<p></p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cerrar</button>
<button data-dismiss="modal" class="btn blue" id="deleteok">Confirmar</button>
</div>
</div>
<!-- end modal -->
然后我的JS文件是:
function callToModal(data) {
$("#myModal3 .modal-header h3").html("Eliminar");
$("#myModal3 .modal-body p").html("Are you sure you want to delete: ", data);
$("#myModal3").modal("show");
}
任何帮助将非常感激!
最终,在搜索了smarty和js sintax之后,我发现了问题所在。
简单来说,它需要一些''包装参数。
因此,从SMARTY向JS发送参数的正确方法是:
<td><a href="#" onclick="callToModal('{$frontuser->username}');" class="btn mini red-stripe" role="button" >Eliminar</a></td>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句