我如何... jquery popupform函数onclick()标签< a />剂量不适用于ASP.NET MVC [英] How do i...jquery popupform function onclick() tag <a/> dose not work in ASP.NET MVC
本文介绍了我如何... jquery popupform函数onclick()标签< a />剂量不适用于ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Quote:
每个人
我需要使用ASP.NET MVC在onclick事件标记内调用jquery popupform函数,每个东西看起来都很好但是当我点击btn时添加新的jquery popupform函数剂量不打开以及返回json数据剂量不执行
请查看我的代码并回复遗漏的错误
谢谢
Hi, Everybody
I need to call a jquery popupform function inside the onclick event tag a using ASP.NET MVC, Every thing is looking fine but when I click on the btn add new the jquery popupform function dose not open and also the return json data dose not execute
Please have a look to my code and reply the missing error
Thanks
@{
ViewBag.Title = "Employee List";
}
<h2 class="mt-3">Employee List</h2>
<a id="btnclick" class="btn btn-primary mb-2 ml-2" style="color:white" onclick="Popupform('@Url.Action("AddOrEdit","Employee")')"> Add New</a>
<table id="TableEmployee" class="table table-striped table-bordered w-100" >
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</thead>
</table>
<link href="https://cdn.datatables.net/1.10.16/css/dataTables.bootstrap4.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
@section scripts{
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/dataTables.bootstrap4.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var popup, datatable;
datatable = $("#TableEmployee").DataTable({
"ajax": {
"url": "/Employee/GetData",
"type": "GET",
"datatype": "Json"
},
"columns": [
{ "data": "Name" },
{ "data": "Position" },
{ "data": "Office" },
{ "data": "Age" },
{ "data": "Salary" }
],
"Language": {
"TableEmployee": "No data found, Please click on Add New Button"
}
});
$(".btn.btn-primary").click(function () {
alert('Hello this is jquery btn');
function Popupform(url) {
var formDiv = $('div/');
$.get(url)
.done(function (response) {
formDiv.html(response);
popup = formDiv.dialog({
autoOpen: true,
resizable: false,
title: 'Fill Employee Details',
height: 500,
width: 700,
close: function () {
popup.dialog('destroy').remove();
}
});
});
}
});
});
</script>
}
[HttpGet]
public ActionResult AddOrEdit(int id=0)
{
return View(new Employee_tb());
}
推荐答案
(document).ready(function(){
var popup,datatable;
datatable =
(document).ready(function () { var popup, datatable; datatable =
(#TableEmployee)。DataTable({
ajax:{
url:/ Employee / GetData,
type:GET,
datatype:Json
},
columns:[
{data:Name},
{data:Position},
{data:Office},
{data: 年龄},
{数据:薪水}
],
语言:{
TableEmployee:未找到数据,请点击添加新按钮
}
});
("#TableEmployee").DataTable({ "ajax": { "url": "/Employee/GetData", "type": "GET", "datatype": "Json" }, "columns": [ { "data": "Name" }, { "data": "Position" }, { "data": "Office" }, { "data": "Age" }, { "data": "Salary" } ], "Language": { "TableEmployee": "No data found, Please click on Add New Button" } });
(。btn.btn-primary)。点击( F unction(){
alert('你好这是jquery btn');
函数Popupform(url){
var formDiv =
(".btn.btn-primary").click(function () { alert('Hello this is jquery btn'); function Popupform(url) { var formDiv =
这篇关于我如何... jquery popupform函数onclick()标签< a />剂量不适用于ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文