Home > Web Front-end > JS Tutorial > Add the function of 'automatically remembering the position when closed' to jquery.ui.dialog_jquery

Add the function of 'automatically remembering the position when closed' to jquery.ui.dialog_jquery

WBOY
Release: 2016-05-16 18:41:10
Original
1054 people have browsed it

After exploration, it has been expanded to add the function of "automatically remembering the position when closed". The source code is as follows:

Copy code The code is as follows :

//myJquery.ui.dialog.ex.js

/////////////////////// /////////////
//Automatically remember the position when jquery.ui.dialog is closed
///////////////// ///////////////////
(function($){
var originClose = $.ui.dialog.prototype.close;
$.ui. dialog.prototype.close = function()
{
//Determine whether the option specifies not to use this function, such as $("#d").dialog({rememberPosition:false});
if (this.options.rememberPosition != false)
{
this.position = this.uiDialog.offset() ;
var top = $('body').scrollTop();
if (top == 0) top = $(document).scrollTop(); //Fix!DOCTYPE BUG
var left = $('body').scrollLeft();
if(left == 0) left = $(document).scrollLeft(); //Fix!DOCTYPE BUG
this.options.position = [this.position.left-left,this.position.top-top];
}
originClose.apply(this,arguments);
};
})(jQuery);

The principle is very simple, no special explanation will be given, friends who have this need can refer to it one time.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template