EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: aswzen on February 25, 2016, 12:04:52 AM



Title: Change window position? [SOLVED]
Post by: aswzen on February 25, 2016, 12:04:52 AM
How to change window position on first load or by the dynamic way?
already tried with bottom and right css but have no good results

see this fiddle: http://jsfiddle.net/22jL2hgt/

thank you in advance


Title: Re: Change window position? [UNSOLVED]
Post by: jarry on February 25, 2016, 02:00:08 AM
Please try to extend a 'moveTo' method to achieve this functionality.
Code:
(function($){
    $.extend($.fn.window.methods, {
        moveTo: function(jq, param){
            return jq.each(function(){
                var win = $(this).window('window');
                var width = win.outerWidth();
                var height = win.outerHeight();
                var left = undefined;
                var top = undefined;
                if (param.indexOf('left') >= 0){
                    left = $(document).scrollLeft();
                }
                if (param.indexOf('right') >= 0){
                    left = $(window).outerWidth() - width + $(document).scrollLeft();
                }
                if (param.indexOf('top') >= 0){
                    top = $(document).scrollTop();
                }
                if (param.indexOf('bottom') >= 0){
                    top = $(window).outerHeight() - height + $(document).scrollTop();
                }
                $(this).window('move', {
                    left: left,
                    top: top
                });
            })
        }
    });
})(jQuery);

Call $('#win').window('moveTo', 'right bottom') to move a window to the right bottom corner. Please refer to http://jsfiddle.net/22jL2hgt/1/


Title: Re: Change window position? [UNSOLVED]
Post by: aswzen on February 25, 2016, 02:19:48 AM
wow amazing..thankyou jarry :D