tipsy live does not work with jQuery 1.9.0

前端 未结 2 959
無奈伤痛
無奈伤痛 2021-02-12 13:44

We recently upgraded our jQuery to 1.9.0, but it broke our tipsy plugin. Its live functionality now causes an error.

$(\'.tooltip, abbr\').tipsy({
          


        
相关标签:
2条回答
  • 2021-02-12 14:10

    The problem is that this plugin still use .live() to let work the method live you used there, it is deprecated and has been replaced with .on().

    You should try to search for updated version of the plugin or try to replace it by yourself.

    0 讨论(0)
  • 2021-02-12 14:18

    you need to include jquery migration plugin, since you are using live:true it make use of jquery.live which was removed in jquery 1.9.

    For backward compatibility they have created a migration plugin which can be downloaded here and include the migration plugin to add back support for the removed methods and utilities.

    I would be doing something like

    if (options.trigger != 'manual') {
        var eventIn  = options.trigger == 'hover' ? 'mouseenter' : 'focus',
            eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur';
        if(options.live){
          $(this.context).on(eventIn, this.selector, enter).on(eventOut, this.selector, leave);
        } else {
          this.on(eventIn, enter).on(eventOut, leave);
        }
    }
    
    0 讨论(0)
提交回复
热议问题