Modify the location of Jquery Dialog

Source: Internet
Author: User

Modify the location of Jquery Dialog

The dialog component in Jquery UI is used for a function today. It should be a very simple component and many functions are not provided. For example, you can directly obtain the dialog position, it is impossible to directly modify the location of the dialog, and when the drag position is invisible, it is a pitfall. It cannot be closed or dragged, at this time, you can only refresh the page to reinitialize the interface.

I solve this problem today: There are two ways to solve this problem (I think)

1. modify attributes to make the local area visible and drag

2. Do not make the drag area invisible.

In the first case, I did not think of a proper solution. The second solution is provided below. The principle is to judge the current dialog position. If the drag position may be invisible, modify the dialog position at this time, dialog has a method to listen for dialog dragging. My implementation method is placed in this method. The Code is as follows:

 

/*** Add a drag-and-drop listener. Update the UI when it is running out of the screen. * @ param {Object} event * @ param {Object} ui */drag: function (event, ui) {var posX = ui. position. left; var posY = ui. position. top; if (posX <5) {posX = 5;} if (posY <5) {posY = 5;} ui. position. left = posX; ui. position. top = posY ;}

This is a simple piece of code. There is nothing to say, mainly using some attributes of the ui.

 

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.