2016-09-17 68 views
1

我正在使用由http://davidstutz.github.io/bootstrap-multiselect/提供的bootstrap multiselect插件。我遇到了悬停在所有选定值的工具提示上的问题。它会显示意想不到的结果,如给定图像。 tootip unexpected results 我想删除工具提示我也尝试禁用按钮标题属性whoes值显示在工具提示中。但它不起作用。 我现在的代码是这样的。
当前HTML与PHP代码:如何隐藏bootstrap multiselect悬停工具提示?

<select class="form-control" multiple name="speciality[]" id="speciality"> 
<?php if($data=$user->getAllSpecialities()){ 
    foreach($data as $key => $value) {?> 
     <option selected value="<?php echo $value['speciality_id'];?>"> 
       <?php echo $value['speciality_title'];?> 
     </option> 
    <?php } 
}?> 
</select> 


jQuery的与多选初始化:

$('#speciality').multiselect({ 
    nonSelectedText: 'Select Speciality', 
    numberDisplayed: 2, 
    buttonClass: 'btn btn-default', 
    buttonWidth: '100%', 
    includeSelectAllOption: true, 
    allSelectedText:'All',    
    selectAllValue: 0, 
    selectAllNumber: false, 
    maxHeight: 100, 
    onSelectAll: function() { 
     $('button[class="multiselect"]').attr('title',false); 
    } 
}); 
//$('#speciality').tooltip().attr('title', 'all specialities'); 

回答

1

如果我的理解侑问题妥善那么你愿意删除刀尖再试试此

<select class="form-control" data-toggle="tooltip" data-placement="left" title="Tooltip on left" multiple name="speciality[]" id="speciality"> 
<?php if($data=$user->getAllSpecialities()){ 
foreach($data as $key => $value) {?> 
    =<option selected value="<?php echo $value['speciality_id'];?>"> 
      <?php echo $value['speciality_title'];?> 
    </option> 
<?php } }?></select> 

删除工具提示使用该code`

$('#speciality').tooltip('hide') 

或者

$('#speciality').tooltip('destroy') 
+0

亲爱的Aditya,我已经尝试了两种解决方案,你建议,但它不工作仍然得到相同的结果。 – Arshad

+0

是你使用工具提示在那个选择标记或不能你显示我的代码 –

1

我想我找到了自己的答案。我删除了显示为工具提示的按钮的标题属性。我修改的代码在这里。
修订jQuery代码

$('#speciality').multiselect({ 
    nonSelectedText: 'Select Speciality', 
    numberDisplayed: 2, 
    buttonClass: 'btn btn-default', 
    buttonWidth: '100%', 
    includeSelectAllOption: true, 
    allSelectedText:'All',    
    selectAllValue: 0, 
    selectAllNumber: false, 
    maxHeight: 100, 
    onDropdownHidden: function(event) { 
     // to remove the title when dropdown is hidden so we can remove the title generated by the plugin 
     $('button[class="multiselect dropdown-toggle btn btn-default"]').removeAttr("title"); 
    } 
}); 

$('button[class="multiselect dropdown-toggle btn btn-default"]').removeAttr("title"); 
2

要删除你需要重写按钮名称功能在你的选择提示。

$('#speciality').multiselect({ 
nonSelectedText: 'Select Speciality', 
numberDisplayed: 2, 
buttonClass: 'btn btn-default', 
buttonWidth: '100%', 
includeSelectAllOption: true, 
allSelectedText:'All',    
selectAllValue: 0, 
selectAllNumber: false, 
maxHeight: 100, 
onSelectAll: function() { 
    $('button[class="multiselect"]').attr('title',false); 
}, 
buttonTitle: function() {}, 
}); 
+0

谢谢你! – 11teenth

+0

非常感谢 –