Giter Site home page Giter Site logo

sebastien-p / jquery.haseventlistener Goto Github PK

View Code? Open in Web Editor NEW
44.0 4.0 9.0 337 KB

hasEventListener is a jQuery plugin which checks if an Object or a DOM element actually has a particular/live/delegated event listener bound to it.

JavaScript 100.00%

jquery.haseventlistener's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jquery.haseventlistener's Issues

HasEventListener will always return false in IE 7

HasEventListener will always return true do to a IE 7 bug in the get_valid_types_first_letter method. The bug is due to IE 7's short coming of not being able to index strings like arrays. So this line:

var first_try = (/Object|(Ele|Docu)ment|Window/.exec(Object.prototype.toString.call(object)) || [""])[0][0],

needs to be this line:

var first_try = (/Object|(Ele|Docu)ment|Window/.exec(Object.prototype.toString.call(object)) || [""])[0].charAt(0),

If you wanna support IE 7.

feature request - live events

Changed:
first_div = divs.eq(0).click(function (e) {

    window.alert(e.type);

}),

To:
first_div = divs.eq(0).live('click',function (e) {

    window.alert(e.type);

}),

In the JS fiddle, and it turned a 'true' to a 'false'

hasEventListner will not work in JQuery 1.8+ (possible fix for that)

Me again...

The reason for the break is that in JQuery 1.8+ they moved the $.data("events") to $._data('events") as to not mess with someones data-events tag.

I made a quick fix to this by adding a null colace in the get_events_data method on the return line to use
javascript $["_"+DATA](element, EVENTS) if javascript $[DATA](element, EVENTS) doesn't return anything.

compatibility.get_events_data = ($.now && !$.sub) ? function (element) { // 1.4.3 and 1.4.4

        // Workaround for '$({}).bind("event", handler).data("events"); // undefined' bug (on "window" too) !
        var element_type = get_valid_types_first_letter(element),
            data = $[DATA](element, ((element_type = (element_type === "W") || (element_type === "O"))) ? "__" + EVENTS + "__" : EVENTS);

        return ((data && element_type) ? (data || {})[EVENTS] : data);

    } : function (element) {

        return $[DATA](element, EVENTS) || $["_"+DATA](element, EVENTS);

    };

With this change the path we're using $("~selector").hasEventListner('event.namespace') works great.

Thanks,

Zack

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.