tipsy live does not work with jQuery 1.9.0

前端 未结 2 953
無奈伤痛
無奈伤痛 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: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);
        }
    }
    

提交回复
热议问题