繁体   English   中英

jQuery Jtable不适用于第二次单击

[英]Jquery Jtable is not working for 2nd click

我正在尝试在项目中使用JTable,当单击一个按钮时,需要显示JTable,当我单击另一个按钮时,则需要放置另一个数据,当我再次返回时,单击相同的JTable按钮,则JTable是我不知道为什么会这样。 我的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>jQuery jTable Setup in java</title>
<!-- Include one of jTable styles. -->
<link href="css/metro/blue/jtable.css" rel="stylesheet"
    type="text/css" />
<link href="css/jquery-ui-1.10.3.custom.css" rel="stylesheet"
    type="text/css" />
<!-- Include jTable script file. -->
<script src="js/jquery-1.8.2.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.10.3.custom.js" type="text/javascript"></script>
<script src="js/jquery.jtable.js" type="text/javascript"></script>
<script type="text/javascript">
//  $(document).ready(function() {
    function getUser(){
        $('#StudentTableContainer').jtable({
            title : 'Students List',
            actions : {
                listAction : 'Controller?action=list'
            },
            fields : {
                studentId : {
                    title : 'Student Id',
                    width : '30%',
                    key : true,
                    list : true,
                    create : true
                },
                name : {
                    title : 'Name',
                    width : '30%',
                    edit : false
                },
                department : {
                    title : 'Department',
                    width : '30%',
                    edit : true
                },
                emailId : {
                    title : 'Email',
                    width : '20%',
                    edit : true
                }
            }
        });
        $('#StudentTableContainer').jtable('reload');




    }
    //);
    function getAdmin()
    {
        var html='';
        html +='<h1>I am working</h1>';
        $("#StudentTableContainer").html(html);
    }
</script>

</head>
<body>
<button onclick="getUser()"  >User</button>
<button onclick="getAdmin()">Admin</button>
    <div style="width: 80%; margin-right: 10%; margin-left: 10%; text-align: center;">
        <h4>jQuery jTable Setup in java</h4>
        <div id="StudentTableContainer"></div>
    </div>
</body>
</html>

如果要在单击按钮时(例如在“ Admin”按钮中)加载表,则需要使用jtable('load'),下面是代码:

function getAdmin(){
    $("#StudentTableContainer").jtable('load');
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM