JQuery selectmenu wordpress

I am moving the site from regular php to wordpress, and they are currently using the jquery-selectmenu plugin for their favorite menus.

I tried enqueu script in wordpress with no luck head.

The scripts from the previous site are 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 just calls the function and works

 $(function(){ $('select#speedC').selectmenu({style:'dropdown'}); }); 

Now in Wordpress I have 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' ); ?> 

And the script on my page

 <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 triggered?

0
source share
2 answers

After several studies, I found that the existing library is not currently being updated and does not work with jQuery.

Refer to this jQuery.ui.selectmenu.js from now on .

+1
source

I know this is an old question, but by adding it it looks high on Google and can help others.

Most jQuery user interface components are included in WordPress, but are not queued by default; you need to queue them.

  wp_enqueue_script( 'jquery-ui-selectmenu' ); 

There is a useful list of included components and a queue line at http://jafty.com/blog/tag/how-to-use-jquery-ui-in-wordpress/

0
source

Source: https://habr.com/ru/post/1391865/


All Articles