Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
让jQuery插件在wordpress中工作;拇指导航栅格展开预览“;_Jquery_Wordpress - Fatal编程技术网

让jQuery插件在wordpress中工作;拇指导航栅格展开预览“;

让jQuery插件在wordpress中工作;拇指导航栅格展开预览“;,jquery,wordpress,Jquery,Wordpress,我发现了一个极好的jquery教程。 但现在我正试图让它在wordpress中运行,但我似乎无法让jquery正常工作 我将在my functions.php中按如下方式将脚本排队: wp_register_script( 'grid-js', get_stylesheet_directory_uri() . '/library/js/grid.js', array( 'jquery' ), '', true ); wp_enqueue_script( 'grid-js'

我发现了一个极好的jquery教程。 但现在我正试图让它在wordpress中运行,但我似乎无法让jquery正常工作

我将在my functions.php中按如下方式将脚本排队:

wp_register_script( 'grid-js', 
   get_stylesheet_directory_uri() . '/library/js/grid.js', 
   array( 'jquery' ), '', true );
   wp_enqueue_script( 'grid-js' );
我将整个grid.js放在这段代码中,这样我就不会有任何$conflicts:

(function($) { ...code here... })(jQuery);
在本教程中,index.html页面底部有一个标记,用于启动jquery文件。我把它放在索引页的底部,如下所示:

 <script>
    (function($) {
    Grid.init();
    })(jQuery); </script>

(函数($){
Grid.init();
})(jQuery);
但我得到的只是这个错误信息

未捕获引用错误:未定义网格

希望从长远来看,我将通过ajax调用加载扩展的网格,但现在我只考虑让Jquery在wordpress中实际工作

如果有人对如何让jquery插件在wordpress中工作有任何指导或教程,那将是非常好的,我相信其他人会很感激。我花了很多时间在这里和谷歌上搜索,但到目前为止,我还没有找到什么好东西,大部分教程都是关于Enquence的


提前感谢。

您好,我已经成功地实现了这一点

我所做的是:

(function($) {

$(function() {
    grids.init();
    });

})(jQuery);
在它自己的js文件中调用它loadgrid.js,并在my functions.php中注册要加载的脚本

wp_register_script( 'loadgrid', get_stylesheet_directory_uri() . '/library/js/loadgrid.js', array( 'grid-js' ), false , true );
出于某种原因,我无法将其内联,但这样做可以在寄存器页面底部加载它

希望这有帮助