如何调用函数来重新加载另一个函数(在“orientationchange()”上)?

时间:2015-12-10 15:25:48

标签: javascript php jquery function reload

我想重新加载js函数(在 xyz.php 内部),因为移动方向会发生变化(在orientationchange()上)。

在“ jquery-custom.js ”中,我已经有orientationchange()的函数可以运行:

$(window).on('orientationchange', function(e) {
     $(".loader-packery").show().delay(1000).fadeOut(1);
});

这是“ xyz.php ”里面的功能,我想重新加载:

    function searchWidthMobile() {
        if (is_mobile) {
            var $mobile_search = $( ".mobile-header-inner .searchform" );
            if($mobile_search.length){
                $mobile_search.focusin(function() {
                    $(this).css({
                        'z-index':'2'
                    }).stop().animate({
                        'padding-left':'0px',
                        'padding-right':'0px'
                    }, 400);
                });

                if ($(document).width() > 380) {
                    $mobile_search.focusout(function() {
                    $(this).stop().animate({
                        'padding-left':'435px',
                        'padding-right':'77px'
                    },400);
                    setTimeout(function(){
                        $mobile_search.css({
                            'z-index':'0'
                        });
                    }, 400);
                });
                }
                else {
                    $mobile_search.focusout(function() {
                    $(this).stop().animate({
                        'padding-left':'235px',
                        'padding-right':'77px'
                    },400);
                    setTimeout(function(){
                        $mobile_search.css({
                            'z-index':'0'
                        });
                    }, 400);
                    });
                }

            }
        }
    }

    searchWidthMobile();
    //        $(window).resize(searchWidthMobile); 

xyz.php中的函数有效。但正如您可以想象的那样,只有加载或重新加载网站本身。

任何帮助将不胜感激:)

1 个答案:

答案 0 :(得分:1)

只需在设备方向改变时调用该功能:

$(window).on('orientationchange', function(e) {
    $(".loader-packery").show().delay(1000).fadeOut(1);
    searchWidthMobile();
});
相关问题