Bubble editing problem. Table disappear when I use $.fn.dataTable.Editor();

Bubble editing problem. Table disappear when I use $.fn.dataTable.Editor();

papus89papus89 Posts: 2Questions: 2Answers: 0

I try to make a table with CRUD like https://editor.datatables.net/examples/bubble-editing/inTableControls.html, but I can not make to work functions. Until I add $.fn.dataTable.Editor() table shows data, but after I insert this code like in sample data does not load in table, css and table structure disappear.

Here is my whole code:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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>Registered Users</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.3.min.js">
</script>
    <link rel="stylesheet"
    href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css" />
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="js/jquery/dataTables.editor.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/select/1.1.0/js/dataTables.select.min.js"></script>
</head>
<script type="text/javascript">

var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
    
    $('button.new').on( 'click', function () {
        editor
            .title( 'Create new row' )
            .buttons( { "label": "Add", "fn": function () { editor.submit() } } )
            .create();
    } );

    $('#example').on( 'click', 'tbody td', function (e) {
        if ( $(this).index() < 6 ) {
            editor.bubble( this );
        }
    } );

    $('#example').on( 'click', 'a.remove', function (e) {
        editor
            .title( 'Delete row' )
            .message( 'Are you sure you wish to delete this row?' )
            .buttons( { "label": "Delete", "fn": function () { editor.submit() } } )
            .remove( $(this).closest('tr') );
    } );

    $('#example').DataTable( {
        "bJQueryUI" : true,
        "processing" : true,
        ajax: "ListAllUserServlet",
        columns: [
            {
                "data" : "id"
            }, {
                "data" : "userName"
            }, {
                "data" : "firstName"
            }, {
                "data" : "lastName"
            }, {
                "data" : "email"
            }, {
                "data" : "phone"
            }, {
                "data" : "location"
            }, {
                "data" : "gender"
            }, {
                "data" : "birthday"
            },
            {
                data: null,
                defaultContent: '<a href="#" class="remove">Delete</a>',
                orderable: false
            },
        ]
    } );
} );



    </script>

<body>
    <c:if test="${not empty user}">
        <c:out value="Welcome ${user.firstName} ${user.lastName}!" />
    </c:if>
    <button class="href" onclick="document.location.href='LogOutServlet';">Sign
        out</button>

    <table id="example" class="display">
        <thead>
            <tr>
                <th>User id</th>
                <th>User name</th>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Email</th>
                <th>Phone</th>
                <th>Location</th>
                <th>Gender</th>
                <th>Birth date</th>
                <th></th>
            </tr>
        </thead>
    </table>

</body>
</html>

Without error:
http://postimg.org/image/56cll7wbv/

After I add $.fn.dataTable.Editor();
http://postimg.org/image/t1t30bfnz/

I can not figure out why do this, can not found solution on site, neither on google. Any suggestion?

Answers

  • allanallan Posts: 63,125Questions: 1Answers: 10,398 Site admin

    If you have a look in your browser's console, does it show any error messages? I'm going to presume it does. What is that error? Can you give us a link to the page please?

    Allan

This discussion has been closed.