Easyui Windows (window) cross-border problem--limit Easyui window activity range

Source: Internet
Author: User

There is a problem when using the Easyui window (Windows), and when the form is dragged or resized, it will not return if it is out of the browser range.

Because the browser does not display scroll bars. Re-refresh the page as well.

So I wrote a way to implement the scoped form's active range (only visible in the browser's viewable range):


<div id= "Createschoolwindow" class= "Easyui-window" title= "New School"
data-options= "Modal:true,closed:true,minimizable:false,iconcls: ' Icon-add '"
Style= "width:530px; height:380px; padding:10px; " >
<form id= "Createschoolform" method= "POST" >
<table>
<tr>
<td> School Name:</td>
<td><input class= "Easyui-validatebox" type= "text" name= "name" data-options= "Required:true" ></input ></td>
<td> School website:</td>
<td><input class= "Easyui-validatebox" type= "text" name= "WebSite" data-options= "validtype: ' url '"/></ Input></td>
</tr>
<tr>
<td> Contact person Name:</td>
<td><input class= "Easyui-validatebox" type= "text" name= "Linkman" ></input></td>
<td> Contact Phone:</td>
<td><input class= "Easyui-validatebox" type= "text" name= "Linkmanphone" ></input></td>
</tr>
<tr>
<td> School Address:</td>
&LT;TD colspan= "3" ><textarea rows= "4" cols= "name=" addr "></textarea></td>
</tr>
<tr>
<td> remarks:</td>
&LT;TD colspan= "3" >
<textarea rows= "4" cols= "name=" remark "></textarea>
</td>
</tr>
<tr>
&LT;TD colspan= "4" align= "Center" >
<a href= "#" class= "Easyui-linkbutton" onclick= "Createschool ()" icon= "Icon-save" > Save </a>
<a href= "#" class= "Easyui-linkbutton" onclick= "Closecreateschoolwindow ()" icon= "Icon-cancel" > Close </a>
</td>
</tr>
</table>
</form>
</div>


/*

The principle is simple: to register OnMove and onresize events, the cross-border is auto-reply:

*/

$ (document). Ready (function () {


$ ("#createSchoolWindow"). Window ({
Onmove:function (left,top) {
Console.log (this.left+ "-" +top);
if (left<0) {
$ ("#createSchoolWindow"). Window ("resize", {left:0});
}
if (top<0) {
$ ("#createSchoolWindow"). Window ("resize", {top:0});
}
},
Onresize:function (width, height) {
var w=$ (window). width ();//Visible width
var h=$ (window). height ();//Visible height
var left=$ ("#createSchoolWindow"). Window ("Options"). left;//form left distance
var top=$ ("#createSchoolWindow"). Window ("Options"). top;//form Right Distance
if ((width+left) >w) {
$ ("#createSchoolWindow"). Window ("resize", {width:w-left});
}
if ((height+top) >h) {
$ ("#createSchoolWindow"). Window ("resize", {height:h-top});
}
}
});

});


Easyui Windows (window) cross-border problem--limit Easyui window activity range

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.