1

I wan to use DataTables (a jQuery-plugin) for displaying data. Installation and setup is done, searching in my data via DataTables works fine so far. I am using DataTables v1.10.12, my jQuery is stuck to 1.9.1.

I want to disable bindings of events, or have no events at all - how can I do this?

Background

I am developing a plugin for a 3rd party application. This application encapsulates jQuery, I cannot change this.

When using DataTables, I am running into an error

TypeError: Cannot read property 'length' of undefined

Right now, I am working around this issue by

jQuery("#my-table").DataTable({"ordering": false, "paging":false});

I have no clue, where this error comes from, but I have the stack-trace and I am seeing, if I would not bind some events, this problem would not occur. Of course, this is not a good solution, but for time being the only, I can use.

Uncaught TypeError: Cannot read property 'length' of undefined
jQuery.extend.map   @   batch.js?analytics-enabled=true&bamboo-nps-dark-feature=true&devtoolbar=true&is-server-instance=tru…:876
(anonymous function)    @   batch.js?analytics-enabled=true&bamboo-nps-dark-feature=true&devtoolbar=true&is-server-instance=tru…:30520
keyHandler  @   batch.js?analytics-enabled=true&bamboo-nps-dark-feature=true&devtoolbar=true&is-server-instance=tru…:30523
jQuery.event.add    @   batch.js?analytics-enabled=true&bamboo-nps-dark-feature=true&devtoolbar=true&is-server-instance=tru…:4926
jQuery.event.add    @   batch.js?analytics-enabled=true&bamboo-nps-dark-feature=true&devtoolbar=true&is-server-instance=tru…:10312
...
jQuery.fn.extend.bind   @   batch.js?analytics-enabled=true&bamboo-nps-dark-feature=true&devtoolbar=true&is-server-instance=tru…:7673
_fnBindAction   @   jquery.dataTables.js:6533
_fnSortAttachListener   @   jquery.dataTables.js:6154
_fnBuildHead    @   jquery.dataTables.js:3210
_fnInitialise   @   jquery.dataTables.js:4682
(anonymous function)    @   jquery.dataTables.js:1339

With:

jquery.dataTables.js:6526   function _fnBindAction( n, oData, fn )
jquery.dataTables.js:6527   {
jquery.dataTables.js:6528       $(n)
jquery.dataTables.js:6529           .bind( 'click.DT', oData, function (e) {
jquery.dataTables.js:6530                   n.blur(); // Remove focus outline for mouse users
jquery.dataTables.js:6531                   fn(e);
jquery.dataTables.js:6532               } )
jquery.dataTables.js:6533           .bind( 'keypress.DT', oData, function (e){
4
  • Wouldn't off() work? give it DT selector and pass events Commented Sep 6, 2016 at 13:01
  • Tried it, as described at datatables.net/reference/api/off() - does not help. My TypeError occurs from DataTables-constructor. I did not expect this to help, as events are turned after my error occured - but thanks for input! Commented Sep 6, 2016 at 13:49
  • Show HTML markup for #my-table, most likely it has mismatch of columns in the thead and tbody elements or some other structural problems. Commented Sep 10, 2016 at 14:00
  • I upload HTML source to pastebin.com/2As3fvBK. Search for table with id "checkstyle-result-table" (I build a minimal example showing my error). Please be reminded, I am stuck to develop within a framework (Atlassian Bamboo). Commented Sep 12, 2016 at 8:47

1 Answer 1

1

Got the same problem today with jira. It's actually a bug in Atlassian AUI, as they overwrite some code in jquery-hotkey, see https://ecosystem.atlassian.net/browse/AUI-1283 and https://bitbucket.org/atlassian/aui/diff/src/js/jquery/jquery.hotkeys.js?diff2=3a600c290f9c
DataTables tries to register it's own hotkeys and fails.

To fix it, you can

  • Update your bamboo to a newer version
  • Remove the keybinding from DataTables, that means deleting the ' .bind( 'keypress.DT'...' in jquery.dataTables.js#_fnBindAction
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for input, I gonna have a look at it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.