jQuery 选择菜单 wordpress [英] jQuery selectmenu wordpress
问题描述
我正在将一个网站从普通的 php 迁移到 wordpress,目前他们使用 jquery-selectmenu 插件作为他们的选择菜单.
I am moving a site from normal php to wordpress and currently they use jquery-selectmenu plugin for their select menus.
我试图在 wordpress 头中将脚本排入队列,但没有成功.
I have tried to enqueu the script in wordpress head with no luck.
上一个站点的脚本如下所示.
The scripts from the previous site look as follows.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<link rel="stylesheet" href="<?php echo $siteurl; ?>css/custom-theme/jquery-ui-1.8.1.custom.css" type="text/css" />
<script type="text/javascript" src="<?php echo $siteurl; ?>js/select-menu.js"></script>
<script type="text/javascript" src="<?php echo $siteurl; ?>js/init.js"></script>
init.js 只需调用该函数即可工作
init.js simply calls the function and works
$(function(){
$('select#speedC').selectmenu({style:'dropdown'});
});
现在在 Wordpress 中,我在脑海中添加了以下内容.
Now in Wordpress i added the following to my head.
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'template_url' ); ?>/custom-theme/jquery-ui-1.8.1.custom.css" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php wp_enqueue_script( 'jquery-ui-core' ); ?>
<?php wp_enqueue_script( 'swfobject' ); ?>
<?php wp_enqueue_script( 'ui-core-select', get_bloginfo('template_directory') . '/js/select-menu.js' ); ?>
<?php wp_enqueue_script( 'jquery-pajinate', get_bloginfo('template_directory') . '/js/jquery.pajinate.js' ); ?>
<?php wp_enqueue_script( 'jquery-ui', get_bloginfo('template_directory') . '/js/jquery-ui.1.7.2.min.js' ); ?>
还有我页面中的脚本
<script type="text/javascript">
$j=jQuery.noConflict();
// Use jQuery via $j(...)
$j(document).ready(function(){
$j('select#speedC').selectmenu({style:'dropdown'});
});
</script>
任何想法为什么它没有启动?
Any ideas why it is not initiating?
推荐答案
在做了一些研究后,我发现现有的库目前没有保持最新状态,并且不能很好地与 jQuery 配合使用.
After doing some more research I found that the existing library is not currently kept up to date and not playing well with jQuery.
从现在开始参考这个jQuery.ui.selectmenu.js
这篇关于jQuery 选择菜单 wordpress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!