1

I am using a jQuery plugin that needs to add attribute to all inputs in a page.

$("input").attr('lang', 'fa');

I have no problem for adding this to all inputs except for DataTables search box that this code doesn't affect.

I also tried this code but it doesn't work:

$(document).ready(function () {
    var table =   $('#OrdersTable').dataTable();
    $('.dataTables_filter input').attr('lang','fa');
    $("input").attr('lang', 'fa');
});

Edit:
I tried many things but the problem still exists. To see the problem look at this link and type numbers in search box and the input box at the bottom of the page.

0

1 Answer 1

3

CAUSE

DataTables uses <input type="search"> for the search box. For some reason applying lang attribute doesn't have any effect on that input type.

SOLUTION

Changing input type to <input type="text"> fixes the issue.

$('#example').DataTable();
$('.dataTables_filter input').attr({'lang': 'fa', 'type': 'text'});  

DEMO

See jsFiddle for code and demonstration.

Sign up to request clarification or add additional context in comments.

1 Comment

no , it doesn't work . please look at my question edit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.