schnettchen
Forum Replies Created
-
Forum: Plugins
In reply to: [wp-Typography] GDPR / DSGVOThanks a lot!
Forum: Developing with WordPress
In reply to: How to insert a jQuery script in a wordpress page?Hi there,
after searching for hours without finding a solution to my problem I’ll ask my question here. It concerns this topic, so I’ll just put it here.I developed a simple plugin using jquery. I cannot find a way to get it running with the jquery libraries included by wordpress. When I dequeue WordPress-jQuery and enqueue jQuery again from google it works (except the “jquery is undefined” error).
The code in my jquery file has the following structure:
$(function($){ [code of the document ready functions] })(jquery); function xy(){ $(#id).doSomething; ... };In my Plugins PHP file I enqueue my scripts this way:
function add_paketkonfigurator_scripts(){ wp_register_script('paketkonfigurator_script',plugins_url( 'js/paketkonfigurator.js', __FILE__ ), array( 'jQuery' ),'1.0', true); wp_enqueue_script('paketkonfigurator_script'); wp_register_style('paketkonfigurator_style',plugins_url( 'css/paketkonfigurator_style.css', __FILE__ )); wp_enqueue_style('paketkonfigurator_style'); } add_action( 'wp_enqueue_scripts', 'add_paketkonfigurator_scripts' );When looking at the pages source code they are included (in the header?) directly after jquery (before the content code of the page - shouldn't they be loaded below?):
<script type='text/javascript' src='https://homepage.com/wp-includes/js/jquery/jquery.js?ver=1.12.4'></script> <script type='text/javascript' src='https://homepage.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script> <script type='text/javascript' src='https://homepage.com/wp-content/plugins/Stb%20Gebühren%20Plugin/js/gebuehrenrechner.js?ver=4.8.3'></script> <script type='text/javascript' src='https://homepage.com/wp-content/plugins/Stb%20Gebühren%20Plugin/js/paketkonfigurator.js?ver=4.8.3'></script>I already tried different things. Replaced all '$' with 'jQuery', put a'$' before the "jQuery in no conflict mode wrapper" (somewhere I read that you have to put one at the beginning when the scripts are loaded in the header). I also wrapped all functions between
(function( $ ) { "use strict"; // javascript code here. i.e.: $(document).ready( function(){} ); //my other functions function xy(){}; following })(jQuery);as told in your link. This version doesn't throw any errors at least. But the program doesn't work either... In the other cases i alwas get the error "ReferenceError: jquery is not defined" and "TypeError: a.indexOf is not a function" in "
jquery.min.js:4:18892". These errors also come up when I enqueue Googles jQuery....So i have no idea where my mistake / misunderstanding is and running out of time :/
I hope someone can help.Best regards,
Jeannette- This reply was modified 8 years, 7 months ago by schnettchen.
- This reply was modified 8 years, 6 months ago by bcworkz. Reason: code fixed, 1st backtick must be in col 0
Forum: Plugins
In reply to: [Max Mega Menu] Hovering over Mega-Menu items: flickering problemHey Tom,
thanks a lot, flickering is done 🙂
Best regards, JeannetteForum: Plugins
In reply to: [Max Mega Menu] Hovering over Mega-Menu items: flickering problemHi, thank you for your answer. I’ll check the error…
My problem with the solution in your link is that I’m not allowed to modify source code directly (the page is hosted by wordpress.com). The only way for me is to install plugins. Is there any possibility to disable the themes navigation-configurations via a plugin? I tried
wp_deregister_script('wp_nav_menu');in my plugins .php, but nothing happens :/Regards, Jeannette
- This reply was modified 8 years, 9 months ago by schnettchen.