How to add DOM feature in Ajax stocks datatables?

0

I am trying to create a live crypto currency price chart with jQuery, Javascript, Ajax and Websocket. Datatable is using for sorting purpose. Live crypto currency price is always appearing in input. It will always work outside of the datatable table. But if I put input in the datatable table, live price is not appearing.

I searched in google and found the solution. DOM function needed to getting live number value in datatable input. I am using this https://datatables.net/examples/advanced_init/stocks.html datatable for my project. I got DOM javascript code for live DOM number sorting.


<script type="">
 $.fn.dataTable.ext.order['dom-text-numeric'] = function (settings, col) {
     return this.api()
         .column(col, { order: 'index' })
         .nodes()
         .map(function (td, i) {
             return $('input', td).val() * 1;
         });
 };
 
 $(document).ready(function () {
     $('#example').DataTable({
         columns: [
             { orderDataType: 'dom-text-numeric' },
         ],
     });
 });
 </script>

These are the javascript code for live DOM soring. I don’t know how/where put this codes in my Ajax javascript file

These are the javascript code for live DOM soring. I don’t know how/where put this codes in my Ajax javascript file.

In the ajax javascript fie, I added,

return type === 'display' ?
'<input type="text" id="btc-price" value="">' :
val;

So <input> is appearing in web page without live crypto price. I think DOM is missed in this datatable. I tried many times. But all my efforts was failure… Codepen preview: https://codepen.io/themecode/pen/VwxPOpJ Please help me…