error when using currency type detection plugin
error when using currency type detection plugin
I am having an issue similar to the one reported in this post: http://www.datatables.net/forums/discussion/11168/sorting-currency/p1
>> Uncaught TypeError: Object # has no method '_fnEscapeRegex'
Using
jQuery 1.9.1
DataTables 1.9.4
Chrome 33
OSX 10.7.5
As per the type detection documentation:
[quote]To use of one of the plug-in type detections functions below, you simply need to include it and its counterpart sorting function, in the Javascript available for your page, after you load the DataTables library, but before you initialise the DataTable.
[/quote]
Order of ops:
- load jQuery source
- load DataTable source
- load currency type detection (https://datatables.net/plug-ins/type-detection) and then sort (https://datatables.net/plug-ins/sorting) plugin source
- initialize the datatable
The problem appears to be in the following line of the currency detection plugin:
[code]// Init the regex just once for speed - it is "closure locked"
var
str = jQuery.fn.dataTableExt.oApi._fnEscapeRegex(validChars),
re = new RegExp('[^'+str+']');
[/code]
The function _fnEscapeRegex and the rest of the functions that constitute oApi, are not added to oApi until the DataTable is initialized. When the currency type detection plugin source is loaded the closure is executed. This closure executes an oApi method, which as this point does not exist.
Once i removed this method and escaped the string literal, the plugins worked just fine.
I have looked at the documentation. However, I can't fine a place where the type detection & sorting plugins can take advantage of the oApi.
Carlos
>> Uncaught TypeError: Object # has no method '_fnEscapeRegex'
Using
jQuery 1.9.1
DataTables 1.9.4
Chrome 33
OSX 10.7.5
As per the type detection documentation:
[quote]To use of one of the plug-in type detections functions below, you simply need to include it and its counterpart sorting function, in the Javascript available for your page, after you load the DataTables library, but before you initialise the DataTable.
[/quote]
Order of ops:
- load jQuery source
- load DataTable source
- load currency type detection (https://datatables.net/plug-ins/type-detection) and then sort (https://datatables.net/plug-ins/sorting) plugin source
- initialize the datatable
The problem appears to be in the following line of the currency detection plugin:
[code]// Init the regex just once for speed - it is "closure locked"
var
str = jQuery.fn.dataTableExt.oApi._fnEscapeRegex(validChars),
re = new RegExp('[^'+str+']');
[/code]
The function _fnEscapeRegex and the rest of the functions that constitute oApi, are not added to oApi until the DataTable is initialized. When the currency type detection plugin source is loaded the closure is executed. This closure executes an oApi method, which as this point does not exist.
Once i removed this method and escaped the string literal, the plugins worked just fine.
I have looked at the documentation. However, I can't fine a place where the type detection & sorting plugins can take advantage of the oApi.
Carlos
This discussion has been closed.
Replies
Allan
Thanks Allan!