troubleshooting Question

Javascript attach events through an object

Avatar of skillilea
skillilea asked on
JavaScriptjQuery
5 Comments1 Solution224 ViewsLast Modified:
I am trying to dynamically create events through a user clicking on the row.


I load the click function in jQuery like this:

I keep getting an error that the element passed is not an object.

Is there a better way to create these events?

Do I use attachEvent or addEventListener??

thanks tons for the help.



    $('#jqAOITab').on('click', 'tr:gt(1)', function () {
        var c = new IPImpactControl($(this));
    });




function IPImpactControl(elem) {
    this.ElemTR = elem;
    this.attachEvents();
}


IPImpactControl.prototype = {

    attachEvents: function () {
        var that = this;
        [b]addEventListener(this.ElemTR, 'mouseleave', function () { that.Leave(); });
[/b]        console.log(this.ElemTR);
    },

    Leave: function () {
        var that = this;
        console.log('leave');
        //that.one(console.log('leave'));
    }



};
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros