У меня есть функция поиска по дате, которая отлично работает при вводе полного ввода даты, например :( '30.10.2009'), но если я набираю его, например :( '10 /'), он выбрасывает ajax ошибка (скриншот прилагается).
МОЙ файл bal.js:
$(document).ready(function() {
$("table[role='bal_datatable']").each(function() {
var table = $(this).DataTable({
"order": [
[7, "desc"]
],
columnDefs: [{
"searchable": false,
"targets": 9
},
{
"searchable": false,
"targets": 10
},
{
"orderable": false,
"targets": 9
},
{
"orderable": false,
"targets": 10
},
{
"className": "abc",
"targets": [5]
}
],
autoWidth: false,
pageLength: 50,
processing: true,
serverSide: true,
ajax: $(this).data('url')
});
// Setup - add a text input to each footer cell
$('#balances tfoot th').each(function(i) {
var title = $(this).text();
$(this).html('<input type="text" placeholder="' + title + '" />');
$('input', this).on('keyup change', function() {
if (table.column(i).search() !== this.value) {
table
.column(i)
.search(this.value)
.draw();
}
});
});
});
})
Мой bal_datatable.rb:
def bal_method1(balances)
if(@tabular.search7 > '00/00/0000' )
balances.where("balances.updated_at > (:search) and balances.updated_at < (date (:search) + interval '1 day')", {search: "#{@tabular.search7}"})
else
balances.where("1 = 1")
end
end
Пожалуйста, помогите.