Datatable conflict with Dojo

Datatable conflict with Dojo

soldierttsoldiertt Posts: 3Questions: 0Answers: 0
edited December 2013 in DataTables 1.9
Hi,

I notice a very annoying conflict between datatable and dojo.js

Trying this simple example :
[code]







$(document).ready(function() {
$("#mytable").dataTable();
});





Name


Test




[/code]

Give me the js error : Uncaught TypeError: Object [object Object] has no method 'dataTable'

p.s : i'm using the Alfresco Share 4.2.0 product that includes dojo.js so i don't have the ability to remove this dependency.

Anybody knows how can i workaround on this ?

Thank you !

Replies

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    Can you link to the page please? Perhaps try changing `$` for `jQuery` in your above code.

    Allan
  • soldierttsoldiertt Posts: 3Questions: 0Answers: 0
    Hi Allan,

    Using jQuery doesn't help, please find the behaviour here : http://jsfiddle.net/6R6G3/ (two external resources) and look at your browser javascript console.

    Regards.
  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    Not sure what is going wrong there, but DataTables 1.10 resolves the issue: http://jsfiddle.net/6R6G3/1/ .

    Allan
  • soldierttsoldiertt Posts: 3Questions: 0Answers: 0
    Great news, thank you very much.
  • theforkthefork Posts: 1Questions: 0Answers: 0
    I'm not sure this is actually fixed.

    I can only get DataTables to work when Dojo is configured in non-async mode. See this fiddle:
    http://jsfiddle.net/thefork/aTuyn/

    See Fiddle Options -> Framework script attribute -> [code]data-dojo-config="async:true"[/code]
    The console error is still
    [code]Uncaught TypeError: Object [object Object] has no method 'dataTable' [/code]

    DataTables won't load when async:true, but if async:false is set instead then it works.

    We use Dojo as a primary JS framework and it's loaded before jQuery, but DataTables is better than any dojo-based table (kudos) but it doesn't seem to load with an async dojo loader which is a common configuration for anyone using dojo. jQuery seems not to be the issue here.
  • mmodicammodica Posts: 2Questions: 0Answers: 0

    I have the same problem. Demostrated in fsFiddle!!! i revert to 1.9.3 version to immediately solve it...but i need a solution. Can someone find a workaround?

  • mmodicammodica Posts: 2Questions: 0Answers: 0

    The problem is for data-dojo-config="async:true" setted before loading jQuery a Datatables library.

This discussion has been closed.