簡體   English   中英

如何調用一個函數來重新加載另一個函數(例如在“ orientationchange()”上)?

[英]How to call a function to reload another function (on “orientationchange()” e.g.)?

我想在移動方向更改時(在directionchange orientationchange() )重新加載js函數(在xyz.php內部)。

在“ jquery-custom.js ”中,我已經有了一個用於directionchange 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中的功能起作用。 但是您可以想象,僅在加載或重新加載網站本身時。

任何幫助,將不勝感激 :)

只需在設備方向更改時調用該函數:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM