jQuery-contextMenu icon indicating copy to clipboard operation
jQuery-contextMenu copied to clipboard

Support Radio Input Label `for` Attribute

Open onet4 opened this issue 7 years ago • 1 comments

Nice plugin.

When I create a menu with radio inputs, clicking on the radio label text does not check the radio button for the first time. Multiple clicks seem to be required.

My suggestion is to give those radio buttons the temporary id attribute and set the for attribute to the label tag with the value of the radio id.

I did this with the show callback but the menu started moving jittery. So it should be better built-in.

events: {
    show: function(opt) {
        var $this = this;   
        opt.$menu.find( 'input[type=radio]' ).each( function( index, value ){
            var _id = 'context-menu-radio-' + index;
            $( this ).attr( 'id', _id );
            $( this ).parent().attr( 'for', _id ); // label tag misses the for attribute
        } );
...

onet4 avatar Oct 17 '18 11:10 onet4

Seems an reasonable idea. Thanks.

bbrala avatar Oct 18 '18 07:10 bbrala