Can I use jquery and data tables with jstl ???

Can I use jquery and data tables with jstl ???

alwaysalways Posts: 6Questions: 0Answers: 0
edited June 2010 in General
Hi !

I'm using jstl, and I'd like to use dataTables, but It doesn't work, have anybody done this before ??? How ???
My code, I've made a lot of proofs and I changed the original code, but it doesn't work yet, now the error is " object expected " and then "jquery is undefined". I also try to import de js's files with and
var $j =jQuery.noConflict(); and the error was "jQuery is undefined""
[code]



window.onLoad= CreateTable();


var $j = jquery.jQuery.noConflict();
var oTable;
$j(document).ready(function() {

CreateTable();
});
function CreateTable(){

/* Init the table */
oTable = $('#example').dataTable({
"bPaginate":true,
"iDisplayLength": 50 ,
"bLengthChange": false,
"bFilter": false,
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"aoColumns": [
{sWidth: '20px'},
{sWidth: '20px'},
{sWidth: '30px'},
{sWidth: '50px'},
{sWidth: '50px'},

],
"oLanguage": {
"sLengthMenu": "Mostrar _MENU_ rexistros por paxina",
"sZeroRecords": "Non existen rexistros",
"sInfo": "Mostrar de _START_ a _END_ de _TOTAL_ rexistros",
"sInfoEmtpy": "Mostrar de 0 a 0 a 0 registros",
"sInfoFiltered": "(filtrado de _MAX_ rexistros totais)",
"sSearch": "Procurar" ,
"oPaginate":{
"sNext": "Seguinte",
"sFirst": "Primeiro",
"sPrevious":"Anterior",
"sLast":"Ultimo"
}
}



});
}
[/code]

It seems not to read the js's files.
Any idea ??
Thanks

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    A few things here:

    1. I'd recommend upgrading to jQuery 1.4 - DataTables isn't tested with 1.2 at all any more (it might well work - it might well not :-) )

    2. $j(document).ready(function() - isn't going to work (some of the times - it might for Safari, Firefox etc if the DOM loads quickly enough - which it should), since you have put in your own window.onload event handler. This might just be hacked in testing code though.

    3. $('#example').dataTable({ - should that be $q()... ?

    4. - I've no idea what this does :-). I guess it's an include of some sort - and it doesn't look like it's working as expected. I'd suggest asking at a ColdFusion site (or whatever language it is that you are using).

    Allan
  • alwaysalways Posts: 6Questions: 0Answers: 0
    Hi, thanks for answering me,

    So, now I,m trying this code:

    [code]



    var oTable;
    $(document).ready(function() {
    alert("document ready");
    CreateTable();
    });
    function CreateTable(){
    oTable = $('#example').dataTable({
    "bPaginate":true,
    "iDisplayLength": 50 ,
    "bLengthChange": false,
    "bFilter": false,
    "sPaginationType": "full_numbers",
    "bAutoWidth": false,
    "aoColumns": [
    {sWidth: '20px'},
    {sWidth: '20px'},
    {sWidth: '30px'},
    {sWidth: '50px'},
    {sWidth: '50px'},
    ],
    "oLanguage": {
    "sLengthMenu": "Mostrar _MENU_ rexistros por paxina",
    "sZeroRecords": "Non existen rexistros",
    "sInfo": "Mostrar de _START_ a _END_ de _TOTAL_ rexistros",
    "sInfoEmtpy": "Mostrar de 0 a 0 a 0 registros",
    "sInfoFiltered": "(filtrado de _MAX_ rexistros totais)",
    "sSearch": "Procurar" ,
    "oPaginate":{
    "sNext": "Seguinte",
    "sFirst": "Primeiro",
    "sPrevious":"Anterior",
    "sLast":"Ultimo"
    }
    }



    });
    }

    [/code]

    I didn't upgrade to jQuery 1.4 yet, but I will.
    The alert doesn't appear, any idea ??
  • alwaysalways Posts: 6Questions: 0Answers: 0
    Oh, i forgot, I'm using Java and jstl library.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    If you load "WEB-INF/js/jquery-dataTables.js" as a relative path in your web-browser does it load as expected? You might want to put 'type="text/javascript"' on those script tags as well. If that doesn't help can you post a link please.

    Allan
  • alwaysalways Posts: 6Questions: 0Answers: 0
    Hi, I've just tried "WEB-INF/js/jquery-dataTables.js" and the absolute url : "http://localhost:8080/AplicacionMarco_NEW/WEB-INF/js/jquery-dataTables.js" and the browser didn't find anyone of them, I've already put "type="text/javascript""on the script tags.
    Thanks, any idea left ????
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    If http://localhost:8080/AplicacionMarco_NEW/WEB-INF/js/jquery-dataTables.js gives you a 404 error in your browser, then you've got the URL pointing at the wrong place, or the file is in the wrong place (either way it's the same thing really!). Are you sure you didn't mean jquery.dataTables.js (which is my default file name)?

    Allan
  • alwaysalways Posts: 6Questions: 0Answers: 0
    Hi, i moved all my js's out of WEB-INF, and now when I try http://localhost:8080/AplicacionMarco_NEW/jquery-dataTables.js the browser asks me if I want to open or save the file, but it doesn't show the alert in the
    [code] $(document).ready(function() {
    alert('document ready');
    CreateTable();
    });
    [/code]

    I upgraded jquery to 1.4

    Thanks
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    In that case it looks like jQuery isn't being included correctly... Perhaps need to check the path on that as well. If not, then I'd suggest posting on the jQuery message board to get a hand with getting jQuery going. Also have a look at what errors you might be getting (if any) in Firebug.

    Allan
  • alwaysalways Posts: 6Questions: 0Answers: 0
    ok thanks so much, i'll do it !
This discussion has been closed.