jQuery-contextMenu
jQuery-contextMenu copied to clipboard
Support Radio Input Label `for` Attribute
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
} );
...
Seems an reasonable idea. Thanks.