jquery - jQuery 错误:$(...).modal 不是函数
问题描述
我使用此代码调用模态并传递一些数据:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
if (e.CommandName.Equals("editRecord"))
{
GridViewRow gvrow = GridView1.Rows[index];
HfUpdateID.Value = HttpUtility.HtmlDecode(gvrow.Cells[1].Text).ToString();
txtNameUpdate.Text = HttpUtility.HtmlDecode(gvrow.Cells[2].Text);
/*
txtEmailIDUpdate.Text = HttpUtility.HtmlDecode(gvrow.Cells[3].Text);
txtAddressUpdate.Text = HttpUtility.HtmlDecode(gvrow.Cells[4].Text);
txtContactUpdate.Text = HttpUtility.HtmlDecode(gvrow.Cells[5].Text);
*/
lblResult.Visible = false;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(@"<script type='text/javascript'>");
sb.Append("$('#myModal').modal('show');");
sb.Append(@"</script>");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EditModalScript", sb.ToString(), false);
}
}
我正在使用这个版本的 JQuery 和 Bootstrap:
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
但是我在控制台中有这个问题。模态不会打开。
VM2312:1 Uncaught TypeError: $(...).modal is not a function
at <anonymous>:1:15
at Sys._ScriptLoader._loadScriptsInternal (MicrosoftAjaxWebForms.js:6)
at Sys._ScriptLoader._nextSession (MicrosoftAjaxWebForms.js:6)
at Sys._ScriptLoader._loadScriptsInternal (MicrosoftAjaxWebForms.js:6)
at Sys._ScriptLoader._nextSession (MicrosoftAjaxWebForms.js:6)
at Sys._ScriptLoader.loadScripts (MicrosoftAjaxWebForms.js:6)
at Sys.WebForms.PageRequestManager._onFormSubmitCompleted (MicrosoftAjaxWebForms.js:6)
at Array.<anonymous> (MicrosoftAjax.js:6)
at MicrosoftAjax.js:6
at Sys.Net.WebRequest.completed (MicrosoftAjax.js:6)
解决方案
尝试在结尾之前添加您的 bootstrap.min.js 脚本,并在标题中添加 jquery 脚本
推荐阅读
- git - 在 Github 上,问题和拉取请求之间是否存在强制关系?
- ruby-on-rails - 为 Rails 应用程序安装 postgresql 时遇到问题
- r - R中的nlminb有什么问题吗?
- python - 熊猫数据框按列值的下一次出现分组
- angular - 用于动画的 Angular CSS3 关键帧
- javascript - 发布请求后,继续检查是否完成 | 节点.js
- javascript - 用户只能在 Firestore 上读取/写入自己的提交
- jquery - Jquery在页面加载后自动点击
- kubernetes - 如何在 kops 上禁用 --basic-auth-file?Kubernetes
- ssis - 将条件拆分的结果传递给存储过程