2014-04-25 168 views
0

我让我的工具提示工作正常,默认$('selector').tooltip('show'); 然后,我想要所有的花式。这肯定是显而易见的,但我看不到它。Bootstrap工具提示没有显示

的Javascript

initTooltip(
    $element, {'placement': 'bottom', 'title': Messages[$element.id + 'Required']} 
); 

的Javascript:

initTooltip: function($element, options) { 
    $('#' + $element.id).tooltip({ 
     'placement': options.placement, 
     'title': options.title 
    }); 
} 

当我登录了initTooltip的参数,可以这是我得到什么(如预期)

的Javascript:

Object {placement: "bottom", title: "Please enter your Last Name."} 

一切似乎都到位,我也没有得到任何错误。工具提示本身只是不呈现。这就像我需要拨打tooltip.show()什么的。

回答

0

我找到了适合我需求的解决方案。我的失败是“触发”属性。对于任何人遇到这个职位,这里是我在做什么&运作良好。

的JavaScript:

initTooltip($element, {'placement': 'bottom', 'title': Messages[$element.id + 'Required']}); 

的JavaScript:

/** 
* Renders a tool tip for the given input. 
* @param {object} $element | The input element. 
* @param {object} options | Display options. 
* @returns {void} 
* 
*/ 
initTooltip: function($element, options) { 
    $('#' + $element.id).tooltip({ 
     'placement': options.placement, 
     'title': options.title, 
     'trigger': 'manual' 
    }).on({ 
     blur: function() { 
      $('#' + $element.id).tooltip('show'); 
     }, 
     focus: function() { 

     } 
    }); 
} 

我验证使用onInputFocusOut事件文本输入。当发生这种情况时,如果出现错误,我会显示错误,然后渲染工具提示(上图)。

0

分配所有的工具提示类=“TTIP”,利用此功能:

$(document).ready(function(){ 
    $(".ttop").tooltip({ 
    placement : 'top' 
    }); 
}); 

你可以看到我做了这样的事project工作。