Loading loading in the Layer.js
L This article mainly introduces the application of loading loading in Layerjs in the actual project.
1, the use of technology
Front End: Html5+css3+js+layer.js
Back end:. Net
2. Problems encountered
When using the loading provided in the Layer.js plug-in, the corresponding GIF format dynamic graph needs to be found in the layer.css in Layer.js, which needs to be the same size as the loading loaded GIF in the plug-in.
3. Introduction of Load () method in Layer.js
Load does not need to pass too many parameters, according to the style you like to set. The method is available in three styles for selection. And the icon in load supports incoming 0-2, if it is 0, no need to pass in. However, load is not closed by default and needs to be closed in the callback function.
Method One:
var index = layer.load (); Do not pass in parameters, default 0
Method Two:
var index = layer.load (1); Parameter 1, another style
Method Three:
var index = layer.load (2,{time:10*1000}); Parameter 2, in a different style; time setting maximum wait
4, the actual project application
In the corresponding HTML page that needs to load loading to add the code to write loading load, the first page to log on to the screen as an example:
1) Set the login interface's Click event:
$(‘#submit‘).click(function() { $(this).css(‘background‘,‘green‘);//设置当前点击登录按钮后,改变其登录框的颜色 confirm(); //调用ajax函数})
2) Loading load:
$(function() {$.ajaxsetup ({layerindex:-1, Beforesend:function() {Plug-in before loadingThis.layerindex = Layer.load (0, {shade: [0.01, ' #fff ']}), $ (' #submit '). Val ("Logging in")}, Complete: function () { //after loading Executive Layer.close (This.layerindex); //Finish loading close loading}, Error: function () { //error when executing Layer.alert (' show exception, please retry after refresh ', {skin: ') Layui-layer-molv ', closebtn: 0, Shift: 4 //Animation type}) ;});
5.
Loading loading and layer.js