user2969610
user2969610

Reputation: 89

Mousedown event is not fired in Chrome and Firefox

I have a very annoying problem. In Chrome and Firefox both last version the mousedown event is not fired. IE 11 works fine. http://jsfiddle.net/CyzT8/

Later I would like add and remove widgets, so I can't use the working extract.

        // DOES NOT WORK in Chrome and Firefox
        //$("#content_wrapper").mousedown(".resizer", function (e) {
        //    e.preventDefault();
        //    resizing = true;
        //    frame = $(this).parent();
        //});

        // DOES work in all browsers
        $(".resizer").mousedown(function (e) {
            e.preventDefault();
            resizing = true;
            frame = $(this).parent();
        });

Upvotes: 3

Views: 7020

Answers (2)

AndrewPolland
AndrewPolland

Reputation: 3071

I don't think you can pass the selector in this way on a .mousedown() event. See the documentation at http://api.jquery.com/mousedown/. So the following just won't work:

$("#content_wrapper").mousedown(".resizer", function (e) {
    e.preventDefault();
    resizing = true;
    frame = $(this).parent();
});

Within your fiddle, the second one works fine for me in Chrome and I believe is correct.

$("#content_wrapper").on("mousedown", ".resizer", function (e) {
    e.preventDefault();
    resizing = true;
    frame = $(this).parent();
});

Upvotes: 3

opznhaarlems
opznhaarlems

Reputation: 357

Try this:

$("#content_wrapper").mousedown(".resizer", function (e) {
   e.preventDefault();
   resizing = true;
   frame = $(e.target).parent();
});

Upvotes: 0

Related Questions