This seems like a relatively simple thing but I can't find anything anywhere on how to do it. I have a modal that opens with a disabled input while waiting for async data. I want to know when that input becomes enabled to I can focus the input. This is what I'm trying to accomplish. Think of it as a global modal open handler:
$('.modal').on('shown.bs.modal', function (event) {
var textInput = $(event.target).find('input[type=text]:visible').first();
if (textInput.is(':disabled'))
{
textInput.on('<<<<<enabled>>>>>', function(){
textInput.off('<<<<<enabled>>>>>');
textInput.focus();
});
}
else
{
textInput.focus();
}
});
Is there not an event that gets triggered when an input becomes enabled/disabled?
<input type="text" class="form-control txtUserSearch" data-bind="value: userFilter, event: { keyup: FilterUsers }, enable: AvailableUsers().length > 0">
Which becomes enabled if there are users returned in an async request.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…