Jquery点击打开模式返回“;undefined不是函数”;
Jquery click to open modal returns " undefined is not a function"
我试图用鼠标点击打开一个模态,但似乎根本无法让它工作。这是我的代码
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery-ui-1.10.4.custom.min.js"></script>
<script type="text/javascript">
$("#Attack1Id").click(function () {
var location = $.find("#dialog");
$(location).dialog({
title: "Dialog box",
height: 300,
modal: true,
open: function (event, ui) {
$(this).load("@Url.Action("FileTables", "Card")");
},
on: ('click', '.table a', function () {
alert($(this).closest('tr').find('td:first').text())
})
})
});
</script>
"对话框"似乎是未定义的函数,但我还能怎么创建jquery对话框呢?
更新
为了清楚起见,这是我的整个html页面
@model CardSite.Models.Card
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery-ui-1.10.4.custom.min.js"></script>
@{
ViewBag.Title = "Card";
}
<h2>New card type</h2>
@using (Html.BeginForm("CreateCard", "Card", FormMethod.Post))
{
@Html.AntiForgeryToken()
<div class="form-group">
@Html.LabelFor(m => m.Name)
<div class="text-box-for">
@Html.TextBoxFor(m => m.Name)
</div>
@Html.LabelFor(m => m.Attack1Id)
<div class="text-box-for">
@Html.TextBoxFor(m => m.Attack1Id)
</div>
<div id="dialog"></div>
</div>
<input type="submit" value="Create" class="btn btn-default" />
}
<script type="text/javascript">
$(document).ready(function () {
$("#Attack1Id").click(function () {
var location = $.find("#dialog");
$(location).dialog({
title: "Dialog box",
height: 300,
modal: true,
open: function (event, ui) {
},
on: ('click', '.table a', function () {
alert($(this).closest('tr').find('td:first').text())
})
})
});
});
</script>
---更新---
我刚刚更新了我的代码,使其看起来像这个
<script type="text/javascript">
$(document).ready(function () {
$("#Attack1Id").click(function () {
$("#dialog").dialog({
title: "Dialog box",
height: 300,
modal: true,
open: function (event, ui) {
$(this).load("@Url.Action("FileTables", "Card")");
},
on: ('click', '.table a', function () {
alert($(this).closest('tr').find('td:first').text())
})
});
});
});
$(document).ready(
$("#dialog").dialog({
title: "Dialog box",
height: 300,
modal: true,
open: function(event, ui) {
$(this).load("@Url.Action("FileTables", "Card")");
},
on: ('click', '.table a', function(){
alert($(this).closest('tr').find('td:first').text())
})
})
);
</script>
模态工作,它出现在页面的开头,我可以关闭,然后点击输入框,它再次出现。但如果我关闭模态,重新打开模态,然后点击视图,它会发出两个警报,就像它创建了不止一个。。。关于如何解决这个问题有什么想法吗?
$.find
和$('selector')
的使用之间似乎存在一些差异。
此代码返回JavaScriptArray对象,因此jQuery的任何函数都不能应用于结果集。即使结果集看起来是相同的。
见此贴
您是否尝试过使用$("#dialog")
来选择对话框?
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery-ui-1.10.4.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#Attack1Id").click(function () {
$("#dialog").dialog({
title: "Dialog box",
height: 300,
modal: true,
open: function (event, ui) {
$(this).load("@Url.Action("FileTables", "Card")");
},
on: ('click', '.table a', function () {
alert($(this).closest('tr').find('td:first').text())
})
});
});
});
</script>
更新:
我觉得你的页面中没有调用你的脚本引用。尝试用以下代码替换脚本引用。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
相关文章:
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 为什么会出现错误,“UncaughtTypeError:undefined不是函数”
- mongoose.connect undefined不是一个函数
- Uncaught TypeError:undefined不是函数-ember js
- jQuery Mobile Undefined不是一个函数
- 未捕获的类型错误:undefined不是函数$
- 使用在函数外部声明的变量的 Javascript 返回值 + undefined
- 为什么Grunt Copy给了我一个'undefined不是函数'警告
- Bootstrap-“;未捕获的类型错误:undefined不是函数;
- Undefined不是函数ImpressPages DatePicker
- 尝试使用.ninnerHTMLlog打印数据,获取错误Uncaught TypeError:undefined不是函数
- 得到“;undefined不是函数“;错误
- Undefined不是Fullcalendar js上的函数
- 使用谷歌地图:一个返回undefined的自定义javascript函数
- jqGrid:undefined不是函数
- Jquery,Uncaught TypeError:undefined不是函数
- $http.post undefined 不是函数
- Ember cli Uncatch TypeError: undefined 不是函数
- Infragistics igGrid Uncatch TypeError: undefined 不是一个函数
- JQuery脚本在Firefox上工作;undefined不是函数“;铬