front end - How to use jQuery(...).material_chip inside WordPress?

Although I have imported materialize.js (v1.0.0) inside my plugin in WordPress with $pluginpath = dirname (plugin_dir_ur

Although I have imported materialize.js (v1.0.0) inside my plugin in WordPress with

$pluginpath = dirname (plugin_dir_url( __DIR__  ));
$pluginpath = str_replace('\\','/',$pluginpath);
$thepath = $pluginpath . '/js_libs/materialize.js';
wp_enqueue_script('wpunity_materialize_jslib', $thepath);

and in my main function

wp_register_script( 'wpunity_materialize_jslib', plugin_dir_url( __FILE__ ) . 'js_libs/materialize.js', null, null, false);

I keep getting

jQuery(...).material_chip is not a function

for this code

<div id="textarea-collaborators" class="chips-autocomplete"></div>

                    <script>
                        jQuery( document ).ready(function() {
                            jQuery('.chips-autocomplete').material_chip({
                                secondaryPlaceholder: 'Your collaborator email',
                                placeholder: 'Your collaborator email'
                            });
                        });
                    </script>

Although I have imported materialize.js (v1.0.0) inside my plugin in WordPress with

$pluginpath = dirname (plugin_dir_url( __DIR__  ));
$pluginpath = str_replace('\\','/',$pluginpath);
$thepath = $pluginpath . '/js_libs/materialize.js';
wp_enqueue_script('wpunity_materialize_jslib', $thepath);

and in my main function

wp_register_script( 'wpunity_materialize_jslib', plugin_dir_url( __FILE__ ) . 'js_libs/materialize.js', null, null, false);

I keep getting

jQuery(...).material_chip is not a function

for this code

<div id="textarea-collaborators" class="chips-autocomplete"></div>

                    <script>
                        jQuery( document ).ready(function() {
                            jQuery('.chips-autocomplete').material_chip({
                                secondaryPlaceholder: 'Your collaborator email',
                                placeholder: 'Your collaborator email'
                            });
                        });
                    </script>
Share Improve this question asked May 19, 2020 at 10:37 Dimitrios VerveridisDimitrios Ververidis 1426 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I found it.

wp_enqueue_script('wpunity_materialize_jslib', $thepath);

has to be called last, after all other calls to enqueue scripts that invoke jQuery.

SOLVED

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742420504a4440588.html

相关推荐

  • front end - How to use jQuery(...).material_chip inside WordPress?

    Although I have imported materialize.js (v1.0.0) inside my plugin in WordPress with $pluginpath = dirname (plugin_dir_ur

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信