0
Я использую bootstrap 3 и имею кнопку и ввод. Я бы хотел показать всплывающую подсказку, если кнопка отключена и скрыть всплывающую подсказку, если вводится кнопка. В моем фрагменте .tooltip('hide')
метод не работает, и я не знаю почему.Tooltip hide/show не работает в Bootstrap
HTML
<div class=" user-attributes">
<input type="text" name="attrName" />
<button type="submit" data-toggle="tooltip" title="Please select attribute name" class="btn btn-default disabled" name="addAttribute" >Add attribute</button>
</div>
Javascript
$('button[data-toggle="tooltip"]').tooltip({
animated: 'fade',
placement: 'bottom',
});
/* allow bootstrap tooltip for disabled buttons */
$('.user-attributes button[type="submit"]').css('pointer-events', 'auto');
$(".user-attributes [name='attrName']").bind('input', function(){
var inputIsEmpty = $(this).val().length < 1;
if (inputIsEmpty){
$('.user-attributes button[type="submit"]').addClass('disabled');
$('.user-attributes button[type="submit"]').removeAttr('type');
$('.user-attributes button[type="submit"]').css('pointer-events', 'auto');
$('button[data-toggle="tooltip"]').tooltip('show');
} else {
$('.user-attributes button[type="submit"]').removeClass('disabled');
$('.user-attributes button[type="submit"]').removeAttr('style');
$('.user-attributes button[type="submit"]').attr('type', 'submit');
$('button[data-toggle="tooltip"]').tooltip('hide');
}
});