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.