简体   繁体   English

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

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

I want to reload a js function (inside xyz.php ) as the mobile orientation changes (on orientationchange() ). 我想在移动方向更改时(在directionchange orientationchange() )重新加载js函数(在xyz.php内部)。

In a " jquery-custom.js " I already have a function for orientationchange() that works: 在“ jquery-custom.js ”中,我已经有了一个用于directionchange orientationchange()的函数,该函数可以工作:

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

This is the function inside " xyz.php " i want to reload: 这是我要重新加载的“ 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); 

The function in xyz.php works. xyz.php中的功能起作用。 But as you can imagine, only on loading or reloading the site itself. 但是您可以想象,仅在加载或重新加载网站本身时。

Any help would be appreciated :) 任何帮助,将不胜感激 :)

Just call the function when the device orientation changes: 只需在设备方向更改时调用该函数:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 覆盖函数(例如“警报”)并调用原始函数? - Override function (e.g. "alert") and call the original function? 如何在Node.js中从客户端调用服务器端功能(例如html button onclick)? - How to call a server side function from client side (e.g. html button onclick) in Node.js? 如何禁用调整大小/方向改变的功能? - How to disable a function on resize / orientationchange? 当值既不是数字也不是字符串类型时,Number() 是否显式调用 toString()? (例如功能) - Does Number() explicitly call toString() when value is neither number nor string type? (e.g. function) 在$(document).ready()上注册功能时的通知 - Notification when function is registered on e.g. $(document).ready() 如何在javascript中创建看起来像点符号的自定义函数? 例如,str.getFirstIndex(); - How to create custom function in javascript that looks like a dot notation? e.g., str.getFirstIndex(); 如何根据外部条件(例如购买的物品数量)切换两个不同的按钮(功能/文本) - How to toggle two different buttons (function/text) based on external condition (e.g. num of items purchase) Vscode 扩展:如何实现 hover function 以将 arguments 添加到命令中,例如,运行带查询的搜索命令 - Vscode extension: how to implement a hover function to add arguments to commands, e.g., to run search command with query (function($){})(jQuery)的含义(例如,在jQuery Enlightenment书中) - Meaning of (function($) { })(jQuery) (e.g., in jQuery Enlightenment book) 期望 function 改变例如数组的长度 - Expect a function to change e.g. the length of array
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM