javascript - Onclick 事件未打开 Bootstrap 模式
问题描述
我正在尝试在单击按钮时打开引导模式,但似乎我的代码没有运行。这是我的代码片段:
<button type="button" class="btn btn-xs btn-default" onclick="openViewUserModal(<?= $users['userid']; ?>); return false;">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
function openViewUserModal(id) {
var data = {
"id": id
};
jQuery.ajax({
url: "includes/viewUser.php",
method: "POST",
data: data,
success: function(data) {
jQuery('body').append(data);
jQuery('#viewUserModal').modal({
backdrop: 'static',
keyboard: false,
show: true
});
}
});
}
单击该按钮不会引起响应。我究竟做错了什么?
解决方案
这应该有效,标记 echo 语句。我认为这是一个错字。
<button type="button" class="btn btn-xs btn-default" onclick="openViewUserModal('<?php echo $users['userid']; ?>');">
<span class="glyphicon glyphicon-eye-open"></span>
</button>
推荐阅读
- postgresql - 我想忽略的更新覆盖字段的 Gorm 模型
- asp.net - 在另一个虚拟目录中运行一个项目以进行调试
- javascript - 双向绑定 [(ngmodel)] 不受 jquery 更改事件的影响
- android - 如何使用我的 customer_id(字符串值)并避免为 Stripe 中的每个新支付会话创建新用户?
- javascript - 构建多个 JavaScript 项目
- c - 使用 Beaglebone Black SPI 上的函数初始化 LCD eadip203-6
- flutter - Flutter 如何备份和恢复 sqflite 数据库?
- android - 用户单击kotlin中的注销按钮后如何返回登录屏幕?
- reactjs - 如何从反应组件类中使用反应弹簧
- django - 使用 Wagtail 页面模型在查询集中获取外键特定字段的最高效的数据库方法是什么