jQuery UI Tooltip with jQuery Validate plugin

自作多情 提交于 2019-12-02 10:57:27

问题


I'm trying to use jQuery Tooltip to display a different colour tooltip for errors. I can do this fine with static content using the tooltipClass and styling that class appropriately.

$(".error").tooltip(
{   
   tooltipClass: "ttError"
}); 

Any class which already already has the error class attribute will work correctly but when I use the validate plugin to dynamically add the error class the tooltip will not display correctly. I've only just started using jQuery more so this is out of my scope at the moment, any pointers appreciated.


回答1:


As ninja said in the comment I just placed the above code in the errorPlacement function for the validate plugin:-

errorPlacement: function(error, element) 
    {
        element.attr('title', error.text());
        $(".error").tooltip(
        {   
            position: 
            {
                my: "left+5 center",
                at: "right center"
            },
            tooltipClass: "ttError"
        }); 
    }


来源:https://stackoverflow.com/questions/18228446/jquery-ui-tooltip-with-jquery-validate-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!