Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#13173 closed bug (notabug)

isTrigger on Internet Explorer

Reported by: tomasloon@… Owned by: tomasloon@…
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:

Description

As you can see at http://jsfiddle.net/tomasdev/bZNLB/

On IE7 and IE8 (haven't tested IE9), when the user clicks the input the evt.isTrigger property on change event is assigned with a true value.

This is inconsistent with other browsers, since it's a real user click and not a jQuery triggered event.

I think it's quite a high bug. May be happening for other events, may be due to IE engine assigning that variable on the event. I dont know what to suggest as fix, making a backwards compatible version.

Change History (5)

comment:1 Changed 6 years ago by dmethvin

Owner: set to tomasloon@…
Status: newpending

Why are you looking at .isTrigger? It is not documented. Do not use it.

IE doesn't fire a change event when you click a checkbox. We have to fire one for you.

comment:2 Changed 6 years ago by tomasloon@…

Status: pendingnew

I was looking at it in order to check whether the event was caused by a manual .trigger() or was a user interaction consequence.

Now I'm using !!evt.originalEvent in order to create a flag where to check if it's native user interaction or not.

What method would you recommend?

comment:3 in reply to:  1 Changed 6 years ago by tomasloon@…

Replying to dmethvin:

Why are you looking at .isTrigger? It is not documented. Do not use it.

IE doesn't fire a change event when you click a checkbox. We have to fire one for you.

By the way, it's pretty interesting that a lot of users are using that .isTrigger to check what I wanted. You can check out at most used knowledge bases such as Stack Overflow.

So this ticket is useful for whoever finds it, it's a write down of what's happening. We should not use undocumented methods/properties/etc.

comment:4 Changed 6 years ago by dmethvin

Resolution: notabug
Status: newclosed

When you trigger an event manually you can pass data, so you could do something like this:

$("#checkbox").on("change", function( event, mydata ) {
    if ( mydata ) {
       console.log("called by trigger");
    }
    else {
       console.log("NOT called by trigger");
    }
});
$("#checkbox").trigger("change", [ true ]);

http://jsfiddle.net/gy4LH/

By the way, it's pretty interesting that a lot of users are using that .isTrigger to check what I wanted. You can check out at most used knowledge bases such as Stack Overflow.

If it's not documented, it may break in the future.

comment:5 Changed 6 years ago by anonymous

BTW I highly do not recommend using custom data in events to check if it's user event or not, since not all implementations across jQuery developers are using that. So there's no guarantee that anyone won't trigger without that useful relying-onto data.

Note: See TracTickets for help on using tickets.