api.jquery.com icon indicating copy to clipboard operation
api.jquery.com copied to clipboard

Event.data should note it's not the `input` event data

Open dmethvin opened this issue 11 years ago • 5 comments

http://bugs.jquery.com/ticket/14725

and suggest that people use event.originalEvent.data.

dmethvin avatar Mar 10 '14 14:03 dmethvin

@ConnorCartwright I think this is another issue you could fix. Would you mind submit a PR?

AurelioDeRosa avatar May 07 '16 23:05 AurelioDeRosa

Hey guys @AurelioDeRosa @dmethvin

Have the input and beforeinput events been renamed to beforeedit and edit events?

"beforeinput and input events renamed to beforeedit and edit events, respectively. These events are now defined by the Edit Events spec."

I created a small demo but I feel like I'm missing something or may have misunderstood:

    $(" input.myInput ").on(" input ", {
        name: 'Connor'
    }, function(event) {
        console.log(event.data);
        console.log(event.originalEvent);
        console.log(event.originalEvent.data)
    });

Here event.data prints out the object with name: "Connor", but event.originalEvent.data is undefined.

connorcartwright avatar May 08 '16 14:05 connorcartwright

I didn't realize the name changed last year. The latest spec is here?

https://w3c.github.io/editing/input-events.html#interface-InputEvent

I thought maybe it would pass data with contenteditable but that doesn't seem to be the case either:

https://jsfiddle.net/9v0mesn1/

I'm not sure because I've never used this event, maybe someone else knows?

dmethvin avatar May 09 '16 02:05 dmethvin

Hey @AurelioDeRosa @dmethvin

Looks like input/before input are still in use.

In your jsfiddle, I'm assuming we should be seeing the content of the div as the event.originalEvent.data after we input? (i.e. if it's empty and you type in 'b', that should appear as the data)

connorcartwright avatar May 10 '16 21:05 connorcartwright

@ConnorCartwright yes I expected there would be an event.data property in that fiddle (since it's a native event). Not sure why there isn't one.

dmethvin avatar May 10 '16 22:05 dmethvin