I have a filter function for a table. The table has four columns that can be filtered: Client, Job, Due, Labels.
It worked fine when I filtered for the text of TD's that have a certain class. But now I have modified the Due column so that some rows now have an Input instead of just text.
So I need to filter on the text of some rows and on the value of the input on other rows.
I tried adding the following line:
+ $(this).find(".filterDue").children().val().toLowerCase().indexOf(due) > -1 && +
But this line causes the error: Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
Here's the code I'm using:
<td
class="filterDue"
id="dueDateTd"
style=""
>
<!--If the job has no Rrules it is a one time job so show the date as an input-->
@if($job['one_time_job'])
<input
type="text"
class="form-control input-sm datepicker filterDueInput"
style="max-width:90px; display:inline; "
name="one_time_job_due_date"
id="one_time_job_due_date"
value=""
onchange="update_one_time_job_due_date()"
>
@else
@endif
</td>
$("#box_dashboard_client,#box_dashboard_job,#box_dashboard_due, #box_dashboard_label").on("keyup", function() {
client = $("#box_dashboard_client").val().toLowerCase();
job = $("#box_dashboard_job").val().toLowerCase();
due = $("#box_dashboard_due").val().toLowerCase();
label = $("#box_dashboard_label").val().toLowerCase();
$(".filter").filter(function() {
$(this).toggle($(this).find(".filterClients").text().toLowerCase().indexOf(client) > -1 && +
+ $(this).find(".filterJobs").text().toLowerCase().indexOf(job) > -1 && +
+ $(this).find(".filterLabels").text().toLowerCase().indexOf(label) > -1 && +
+ $(this).find(".filterDue").children().first().val().toLowerCase().indexOf(due) > -1 && +
+ $(this).find(".filterDue").text().toLowerCase().indexOf(due) > -1)
});
});
I don't understand why this selector is undefined. I can alert out this selector and it shows the proper output. But it is not working as a part of my filtering function.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire