Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live to on #144

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Live to on #144

wants to merge 3 commits into from

Conversation

attaboy
Copy link

@attaboy attaboy commented Apr 2, 2013

Patches Tipsy's "live" option to work with newer versions of jQuery by using the 'on' method to bind events instead of 'live'.

@flashios09
Copy link

the "live option" doesn't work for me.
I use jquery 1.9.0 with "attaboy tipsy" and when i set live: true and append the dom with a html code that contain links(with a specific class) i don't have the tooltip
that's my code:

$('a.live-tipsy').tipsy({live: true});
$('#btn').on('click', function(e) {
    $('body').append('<a href="#" class="live-tipsy" title="A tooltip">Dynamic tooltip</a>');
    e.preventDefault();
});

@bernier
Copy link

bernier commented Aug 8, 2013

@attaboy the latest commits are not fixing the jquery 1.9 "live" issue

Plus, now the latest version of jquery is 1.10.2, your variable majorVersionNumber is wrong and is set to 1.1. Which forces tipsy to use the live event.

Here is a solution:

    if (options.trigger != 'manual') {
        var eventIn  = options.trigger == 'hover' ? 'mouseenter' : 'focus',
            eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur';

        if(!this.live) {
            this[binder](eventIn, enter)['bind'](eventOut, leave);
        } else {
            $(this.context).on(eventIn, this.selector, enter);
            $(this.context).on(eventOut, this.selector, leave);
        }
    }

taitems added a commit to taitems/tipsy that referenced this pull request Aug 22, 2013
@taitems
Copy link

taitems commented Aug 22, 2013

The above code from @bernier doesn't work. I've got it working and created a separate pull.

I'd recommend closing this pull and moving discussion to #166.

@bernier
Copy link

bernier commented Aug 22, 2013

@taitems humm... I can see that you just changed one variable in my code. Mentioning it would have been enough.
The code was working, "this.live" was incorrect which was always binding the events with on().

@taitems
Copy link

taitems commented Aug 22, 2013

@bernier wellllll, yes and no.

  • It was a two line change
  • binder is undefined and caused an error, I changed it to a bind event
  • The above code only ever worked with one scenario
  • We now have a clean pull with no version detection cruft

Considering this project doesn't appear to be maintained any more, the driver should be creating clean simple pulls that require little to no thought for the project owner to merge (if they see fit, or are still watching).

@@ -174,7 +183,7 @@
if (!options.live) this.each(function() { get(this); });

if (options.trigger != 'manual') {
var binder = options.live ? 'live' : 'bind',
var binder = options.live ? jQueryDelegateEventMethod() : 'bind',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace jQueryDelegateEventMethod() with ('on' in this ? 'on' : 'live')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants