Just trying to style a select box on a WordPress project with jQuery using this plugin.
http://plugins.jquery.com/project/stylish-select-box/
jQuery(document).ready(function(){
// select box styles
jQuery('#genre-dropdown').sSelect();
});
When I call it on the select box it displays two copies of .newListSelected (the stylable list) instead of one. Below is the code used to produce the select box.
<?php
$args = array(
'taxonomy' => 'genre',
'id' => 'genre-dropdown',
);
wp_dropdown_categories( $args );
?>
I've tried with 开发者_JAVA技巧no argument for the custom taxonomy and on a totally different page with the same results.
The original URL is dead, and I tested with SelectBoxIt. The following example creates an admin menu that displays a styled categories dropdown. The key detail is to load the jQuery plugin adding the bundled WordPress scripts as dependencies, see Don't dequeue WordPress jQuery.
File wp-content/plugins/my-plugin/styled-dropdown.php
:
<?php
/* Plugin Name: Styled Dropdown */
add_action( 'admin_menu', 'add_menu_so_3216591' );
function add_menu_so_3216591()
{
add_menu_page(
'SI',
'<span style="color:#e57300;">SelectIt</span>',
'edit_pages',
'so-3216591',
'menu_page_so_3216591',
'', // icon default for empty
1 // create before Dashboard menu item
);
}
function menu_page_so_3216591()
{
wp_enqueue_style(
'select-it',
'http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.7.0/jquery.selectBoxIt.css'
);
wp_enqueue_style(
'jquery-ui',
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css'
);
# Will be used as dependency bellow
wp_register_script(
'select-it',
'http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.7.0/jquery.selectBoxIt.min.js'
);
# Main script and dependencies
wp_enqueue_script(
'do-it',
plugins_url( '/js/', __FILE__ ) . 'do-it.js',
array( 'jquery', 'jquery-ui-widget', 'select-it' ) // Dependencies: using bundled WordPress scripts (highly recommended)
);
?>
<div id="icon-post" class="icon32"></div>
<h2>Testing Select Box It</h2>
<p><?php wp_dropdown_categories( array( 'id'=>'select-it-dd' ) ); ?></p>
<?php
}
And the file wp-content/plugins/my-plugin/js/do-it.js
:
jQuery(document).ready(function($)
{
$("#select-it-dd").selectBoxIt(
{
theme: "jqueryui"
});
});
精彩评论