Onclick and onmouseup difference with respect to accordion expand and collapse

Onclick and onmouseup difference with respect to accordion expand and collapse

star*hunterstar*hunter Posts: 3Questions: 1Answers: 0

I have a jquery datatable with accordion logic to show or hide inner contents. I am disabling the accordion and then trying to click on accordion which does not open the child(inner content). But if click event handler is replaced by mouseup I am able to display row child. Why does mouseup respond but onclick doesn't(which is expected)

I disabled accordion columns using:

$("#example td.details-control").each(function(){
    $(this)[0].disabled=true;
}
);

Below is the snippet of accordion logic:

$('#example tbody').on('click', 'td.details-control', function () { . //this works when click is replaced with mouseup
    // display/hide logic here
} );

Answers

  • colincolin Posts: 15,236Questions: 1Answers: 2,598

    Hi @star*hunter ,

    I just tried it here - and as you can see, both the mouseup and the click events are behaving as expected. Could you modify that example to demonstrate the problem, please.

    Cheers,

    Colin

  • star*hunterstar*hunter Posts: 3Questions: 1Answers: 0

    Hi @colin

    Kindly check here

  • colincolin Posts: 15,236Questions: 1Answers: 2,598

    Hi @star*hunter ,

    Ah, yep, sorry, somehow I missed that part of your message - apologies!

    That's the expected behaviour - you can't click on disabled elements - this SO thread here goes into some alternatives that you can do.

    Cheers,

    Colin

  • star*hunterstar*hunter Posts: 3Questions: 1Answers: 0

    Hi @colin

    Just to take this bit forward. What i do understand is that click event won't work with disabled elements(as the thread speaks). But shouldn't the same be with mouseup or for any event (viz mouseover,mouseup etc) for that matter. The live example shows accordion working for mouseup.

  • colincolin Posts: 15,236Questions: 1Answers: 2,598

    My reasoning would be click is an action that has a consequence, and therefore has no meaning on a disabled element. Mouse operations, such as mouseup, mouseover, etc, are nagivation events, so still have meaning. Either way, well outside the scope of DataTables, that's standard web stuff.

    C

This discussion has been closed.