Skip to content Skip to sidebar Skip to footer

Inserting A Link To A Dupe In The Close Popup Here On Stackoverflow

I'm working on some code to insert a link to a dupe in the SO close question popup: What happens when you manually insert a link to a question in the textbox is that some JS kicks

Solution 1:

I think I figured out one way, but it's rather fragile:

$dupeBox.data('events').keydown[1].handler({keyCode: 13})

This triggers the second keydown event handler of this element. And gives a keyCode for the stubbed event object.

UPDATE

found a better way:

You can construct a jQuery.Event object with:

var e = jQuery.Event("keydown", { keyCode: 64 });

And trigger the event with this object:

$dupeBox.trigger(e)

The problem was that the SO code checked whether there was something in the event object:

e(d).keydown(c).bind("paste", null, function(a) {
  a.which || c(this)
})

Post a Comment for "Inserting A Link To A Dupe In The Close Popup Here On Stackoverflow"