1

I'm using the bootstrap editor jquery plugin. I'm trying to set an event listener to the add hyperlink button, but it only gets triggered when the text input next to it is empty, otherwise it does not fire. Here's my jsfiddle. My code:

$('.dropdown-menu button').on('click', function () {
        alert("ADD clicked");
    });

To test the jsfiddle, simple select some text and press add without inputting a URL. Then, select the text again, input a URL and press add, no alert() will be shown.

Any ideas why this is happening?

Cornwell
  • 3,304
  • 7
  • 51
  • 84

1 Answers1

2

Something in this line is changing the behaviour for a reason I can't see right now:

$(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');

If you remove it, seems work, so, something in dropdown (i guess) is doing something wrong for you

user1563056
  • 101
  • 3
  • 1
    +1 The bootstrap library is full of calls to the `event` object's `stopPropagation()` and `preventDefault()` methods. It was hard to follow, but odds are good that one of them is capturing the add button's click event when the input gets a value, and keeping it from triggering your custom event handler. – Troy Gizzi Nov 02 '14 at 23:44