Errore su funzione DataTable

Durex

Nuovo Utente
5 Mag 2014
6
0
0
Mi crea gli input ma poi quando va a caricare la tabella, analizzandolo con firebug mi dice:
TypeError: $(...).DataTable is not a function
var table = $('#example').DataTable();

il mio script è DataTables.

Codice:
<script type="text/javascript">
		$(document).ready(function() {
		// Setup - add a text input to each footer cell
		$('#example tfoot th').each( function () {
		console.log(this)
		var title = $('#example thead th').eq( $(this).index() ).text();
        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
		} );
		// DataTable
		var table = $('#example').DataTable();
		
		console.log(this)
     
		// Apply the filter
		$("#example tfoot input").on( 'keyup change', function () {
        table
            .column( $(this).parent().index()+':visible' )
            .search( this.value )
            .draw();
		} );
		} );
</script>

la mia tabella in HTML:
HTML:
<table id="example" class="tabella"> 
					<thead class="t_title">
						<tr>
							<th>Data</th>
							<th>Area</th>
							<th>Procedura</th>
							<th>Versione</th>
							<th>Pdf</th>
							<th>Zip</th>
						</tr>
					</thead>
					
					<tfoot>
						<tr>
							<th>Data</th>
							<th>Area</th>
							<th>Procedura</th>
							<th>Versione</th>
						</tr>
					</tfoot>
					
					<tbody>
						<tr>
							<td>Prova</td>
							<td>Prova</td>
							<td>Prova</td>
							<td>Prova</td>
							<td><a href=" "> <img height="50" alt="Logo Pdf" src="pdf_icon.png"></a></td>
							<td><a href=""> <img height="50" alt="Logo File" src="file_icon.png"></a></td>
						</tr>
						<tr>
							<td>Prova1</td>
							<td>Prova1</td>
							<td>Prova1</td>
							<td>Prova1</td>
							<td><a href=" "> <img height="50" alt="Logo Pdf" src="pdf_icon.png"></a></td>
							<td><a href=""> <img height="50" alt="Logo File" src="file_icon.png"></a></td>
						</tr>
						<tr>
							<td>Prova2</td>
							<td>Prova2</td>
							<td>Prova2</td>
							<td>Prova2</td>
							<td><a href=" "> <img height="50" alt="Logo Pdf" src="pdf_icon.png"></a></td>
							<td><a href=""> <img height="50" alt="Logo File" src="file_icon.png"></a></td>
						</tr>
					</tbody>
				</table>

Sapete dirmi dov'è l'errore?
grazie
 

criric

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
21 Ago 2010
5.607
54
48
TN
A me funziona, probabilmente non richiami le librerie nel modo corretto
HTML:
<link rel="stylesheet" href="//cdn.datatables.net/1.10.0/css/jquery.dataTables.css" type="text/css"/>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript" src="//cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        // Setup - add a text input to each footer cell
        $('#example tfoot th').each(function() {
            console.log(this)
            var title = $('#example thead th').eq($(this).index()).text();
            $(this).html('<input type="text" placeholder="Search ' + title + '" />');
        });
        // DataTable
        var table = $('#example').DataTable();

        console.log(this)

        // Apply the filter
        $("#example tfoot input").on('keyup change', function() {
            table
                    .column($(this).parent().index() + ':visible')
                    .search(this.value)
                    .draw();
        });
    });
</script>
<table id="example" class="tabella"> 
    <thead class="t_title">
        <tr>
            <th>Data</th>
            <th>Area</th>
            <th>Procedura</th>
            <th>Versione</th>
            <th>Pdf</th>
            <th>Zip</th>
        </tr>
    </thead>

    <tfoot>
        <tr>
            <th>Data</th>
            <th>Area</th>
            <th>Procedura</th>
            <th>Versione</th>
        </tr>
    </tfoot>

    <tbody>
        <tr>
            <td>Prova</td>
            <td>Prova</td>
            <td>Prova</td>
            <td>Prova</td>
            <td><a href=" "> <img height="50" alt="Logo Pdf" src="pdf_icon.png"></a></td>
            <td><a href=""> <img height="50" alt="Logo File" src="file_icon.png"></a></td>
        </tr>
        <tr>
            <td>Prova1</td>
            <td>Prova1</td>
            <td>Prova1</td>
            <td>Prova1</td>
            <td><a href=" "> <img height="50" alt="Logo Pdf" src="pdf_icon.png"></a></td>
            <td><a href=""> <img height="50" alt="Logo File" src="file_icon.png"></a></td>
        </tr>
        <tr>
            <td>Prova2</td>
            <td>Prova2</td>
            <td>Prova2</td>
            <td>Prova2</td>
            <td><a href=" "> <img height="50" alt="Logo Pdf" src="pdf_icon.png"></a></td>
            <td><a href=""> <img height="50" alt="Logo File" src="file_icon.png"></a></td>
        </tr>
    </tbody>
</table>
 

Durex

Nuovo Utente
5 Mag 2014
6
0
0
Grazie infatti sbagliavo a caricare le dataTable.
Un'altra cosa, le input text della dataTable sono in basso sotto la tabella. E' possibile spostarle e posizionarle sopra?
 

criric

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
21 Ago 2010
5.607
54
48
TN
sposta la <tfoot> sopra la <thead>
 
Discussioni simili
Autore Titolo Forum Risposte Data
S [PHP] errore funzione sleep PHP 5
T [Javascript] funzione per attivare analytics... dov'è l'errore? Javascript 14
M [PHP] Errore nell' assegnazione della variabile $this->id su una funzione PHP 1
M errore lettura data nel mysql con funzione Where PHP 1
P problema: la funzione funziona (scusate ill gioco di parole) ma mi da errore time out PHP 8
J Funzione js che da errore Javascript 3
A Funzione exec di php, errore 127 PHP 0
M Errore funzione Javascript 2
S Errore funzione elimina script PHP 4
A errore in una funzione...non riesco ad individuarlo! PHP 4
F funzione do_crypt - errore PHP 10
G Errore funzione per form PHP 2
B errore funzione PHP 1
T Errore nel link "Torna Indietro" [era:Funzione javascript] Javascript 0
K Inserimento query Errore 1366 PHP 4
F errore 1062 su campo nuovo MySQL 4
N Errore interno Access MS Access 2
R mi da errore dove inizia il while PHP 1
R Recupero di permalink di un sito che è stato eliminato per errore WordPress 5
R Yoast SEO errore semafori sempre rossi SEO e Posizionamento 0
S Visualizza l'errore di creazione in MSSQL Database 4
simgia Cordova errore quando cerco di emulare o creare la app Sviluppo app per Android 2
P Errore nell'indirizzo degli elementi HTML e CSS 2
Jensen Errore di sintassi con DELETE PHP 3
H Errore su array associativo PHP 1
FDF182 ERRORE 1292 PHP 4
P errore 404 con javascript Javascript 2
felino Windows 7: errore 80072EFE su Windows Update Windows e Software 1
A errore http://datatables.net/tn/7 PHP 4
M Errore visualizzazione meta tag title e description SEO e Posizionamento 1
A Errore durante il salvataggio Photoshop 0
M Errore configurazione motion detection nvr Hikvision DS-7616 IP Cam e Videosorveglianza 0
voldemort [c] Errore di segmentazione (core dump creato) C/C++ 1
T SSD - errore sistema Hardware 2
R Navigare sito con cURL, mi restituisce errore PHP 0
L File CSV con app inventor da errore Sviluppo app per Android 2
A Errore visualizzazione selezione testo Photoshop 0
I Postman 400 Errore di richiesta non valida Programmazione 0
S Errore PHP - Notice: Undefined index ... PHP 14
U Campo vuoto data errore Fatal error: PHP 2
R Errore UPDATE tabella mysql PHP 1
R W10 Segnalazione di errore su terminale USB Windows e Software 0
G non riesco a capire quale sia l'errore [SQL] MySQL 2
I Errore 80040220 nella newsletter con paginazione Classic ASP 0
E Errore di lettura php in html PHP 8
A php metodo post jquery non da mai errore jQuery 4
W Errore di run-time di Microsoft VBScript error '800a0035' Impossibile trovare il file Classic ASP 0
B Errore unexpected '$variabile' (T_VARIABLE) in your code on line PHP 2
M errore dopo passaggio Php 7.2 PHP 6
S -> Errore PHP 8

Discussioni simili