How do I focus a field on the window modal?
How do I focus a field on the window modal?
FreelancerAcc
Posts: 8Questions: 0Answers: 0
The default setting is to focus the first field of the modal window.
How do I manually focus another one?
How do I manually focus another one?
This discussion has been closed.
Replies
$( 'input', editor.node( 'myField' ) ).focus();
[/code]
should do it.
Regards,
Allan
Allan
I'm trying the following code, but even the alert is displayed, I don't get the focus back to the field I need.
If an invalid numbers is entered, error message is displayed and keep focus on the same field, until a valid number is entered
NOTE: I removed the alert as a test, but still the focus is being lost
$( 'input', editor.node( 'remaining_amount' ) ).on( 'blur', function () {
if ( isNaN( editor.get( 'remaining_amount' ) ) ) {
alert('Remaining amount shoud be a valid number');
$( 'input', editor.node( 'remaining_amount' ) ).focus();
}
} );
Allan
Select "Expenses tab", then "Liabilities and Debt" tab
Try editing any of the records there.
NOTE: You may need to click on any of the table headers (e.g. User Name) to be able to view the DataTable's content (I still need to check why this behavior happens for some DT while other display all the records automatically)
I was able to make it work. The code itself was OK, but I was dragging another error that stated that the space on the table defined by "sScrollXInner" won't fit for 3 other tables, as asked me to either increase it or remove the command. Below is what I had, as soon as I removed the ""sScrollXInner": "150%",", the focus command works perfectly
[code]
$('#exp_liabilities').dataTable( {
"sScrollX": "100%",
"sScrollXInner": "150%",
"sDom": "Tfrtip",
...
[/code]