Date time picker

Date time picker

cuperakcuperak Posts: 2Questions: 1Answers: 0

Hi,

I am using data table to show my data. Also, I should have some date time picker on page but when I put both initialization I have an issue.
js call

<script src="js/jquery-ui-1.10.0.custom.min.js"></script>
<script src="data-table-files/datatables.min.js"></script>
<script src="js/dashboard-table.js"></script>
<script src="js/dashboard-date-picker.js"></script>

dashboard-table.js has code used for initialization for data table and other js function
dashboard-date-picker.js has initialization of date picker

$(document).ready(function () {
    $("#datepicker").datepicker({
        dateFormat: 'dd-mm-yy',
        maxDate: addDays(new Date(), 0)
    });
    function addDays(theDate, days) {
        return new Date(theDate.getTime() - days * 24 * 60 * 60 * 1000);
    }
});

if page is opened, there is message in console

TypeError: $(...).datepicker is not a function, $("#datepicker").datepicker({

If dashboard-date-picker.js is changed

$(document).ready(function () {
    $.noConflict(true);
    $("#datepicker").datepicker({
        dateFormat: 'dd-mm-yy',
        maxDate: addDays(new Date(), 0)
    });
    function addDays(theDate, days) {
        return new Date(theDate.getTime() - days * 24 * 60 * 60 * 1000);
    }
});

Both, date picker and data table are initialized
But, if there is button on which click should be collected selected values from table

var table = $('#dashboardTable').DataTable();
    var allSelectedData = table.rows({ selected: true }).data();

There is message:

TypeError: $(...).DataTable is not a function

var table = $('#dashboardTable').DataTable();

Any idea how to have both things on same page?

I read somewhere that cause might be reading two different js, but I left only js which I really need.

Thanks

This discussion has been closed.