javascript - How to blocks user interaction with the underlying user interface while show loader in jquery? -
here's loader show in ajaxstart:
$(document).ajaxstart(function () { $("#wait").css("display", "block"); }); $(document).ajaxcomplete(function () { $("#wait").css("display", "none"); });
css:
.wait { display:none; position:fixed; z-index:1000; width:400px; height:400px; top:20%; left:35%; padding:2px; }
my problem user can able interact background controls while show loader.i don't want user interaction controls. in advance.
css
.preloader-container { position: fixed; z-index: 1031; width: 100%; height: 100%; top: 0; left: 0; background: transparent; display: block; overflow: hidden; padding: 25%; } .preloader-center { position: absolute; padding: 15px; top: 10%; left:30%; -ms-transform: translatex(-50%) translatey(-50%); -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%); background: transparent; z-index: 1000; font-size: 60px; }
javascript
function showloader(container){ var html = '<div class="preloader-container js-busy-loader"><div class="preloader-center"><img src="http://i49.tinypic.com/j5z8mb.gif"></div></div>'; $(container).find(".js-ajax-loader,.js-busy-loader").remove(); $(container).append(html); } function hideloader(container){ if(typeof container == 'string' && container!==''){ $(container).find(".s-ajax-loader,.js-busy-loader").remove(); }else{ $("body").find(".s-ajax-loader,.js-busy-loader").remove(); } }
example: https://jsfiddle.net/h1wpmxs0/
Comments
Post a Comment