Skip to main content

Bug Tracker

Side navigation

#13173 closed bug (notabug)

Opened January 07, 2013 08:28PM UTC

Closed January 07, 2013 09:25PM UTC

Last modified January 07, 2013 10:05PM UTC

isTrigger on Internet Explorer

Reported by: tomasloon@gmail.com Owned by: tomasloon@gmail.com
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.

Attachments (0)
Change History (5)

Changed January 07, 2013 08:40PM UTC by dmethvin comment:1

owner: → tomasloon@gmail.com
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.

Changed January 07, 2013 09:10PM UTC by tomasloon@gmail.com comment:2

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?

Changed January 07, 2013 09:12PM UTC by tomasloon@gmail.com comment:3

Replying to [comment:1 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.

Changed January 07, 2013 09:25PM UTC by dmethvin comment:4

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.

Changed January 07, 2013 10:05PM UTC by anonymous comment:5

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.