Using jquery-blockui, also disallow tabbing to blocked elements -


cross-post github: https://github.com/malsup/blockui/issues/121

link plugin: http://malsup.com/jquery/block/

while elements blocked cannot clicked, it's still possible use tabulator access them, , use enter activate it. possible skip blocked element when tabbing?

for now, stop user tabbing blocked elements, stops user. it'd better if skip blocked ones.

var proxiedblock = $.fn.block; $.fn.block = function () {     var $elem = proxiedblock.apply(this, arguments);      $elem.on('focusin.kj', function (evt) {         evt.preventdefault();          $(evt.relatedtarget).focus();     });      return $elem; };  var proxiedunblock = $.fn.unblock; $.fn.unblock = function () {     var $elem = proxiedunblock.apply(this, arguments);      $elem.off('focusin.kj');      return $elem; }; 

i had same problem , discussed op here: https://github.com/malsup/blockui/issues/121#issuecomment-129719120 ended going approach allows blocked elements skipped. changed tabindex html attributes of elements blocked. ended being best approach our app didn't have modify blockui code. used tabindex of "-2" because of normal elements blocked had tabindex of -1. example date picker hidden div. didn't want overwrite tabindex of hidden div , possibly confuse 3rd party js. used -2 distinguish between calls , other widgets.

$(this).block(); $(this).find('input,select,a').filter(':not([tabindex=-1])').attr('tabindex',-2);  $(this).unblock(); $(this).find('[tabindex=-2]').removeattr('tabindex'); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -