簡體   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