adinaparaglide
Forum Replies Created
-
So It is fixed.:))
Basically what I have done I restart whole process. After deleting current file (my scriptos.js) and deleteing eneque from function.php. So I started over.
1. enequeue my file inside function.php following this codefunction wpb_adding_scripts() {
wp_enqueue_script(‘mujscript’,get_template_directory_uri().’/myscript.js’,array(‘jquery’), null, false);
}
add_action( ‘wp_enqueue_scripts’, ‘wpb_adding_scripts’);
2.creating my new js.file which I am reffering in enequeue line. myscript.js3.setting authorization rights to this file. In my case I use total commander and changing attributes of my myscript.js file to 644.
4.using trial jquery code inside the myscript.js
jQuery(function($){
$(“#button10”).click(function(){
$(“#button1”).fadeToggle();
$(“#button2”).fadeToggle(“slow”);
$(“#button3”).fadeToggle(3000);
});
});
$ sign in wordpress for jquery can not be as defining jquery. It is just different typo in wordpressEverything should work right now, if not for future problems for newbies like me , using Developement tools in google chrome(f12) help you analyze problem more efficiently. Thanks everyone for your help. 🙂
Forum: Developing with WordPress
In reply to: Problem loading jQuery script from custom file in WordPressSo It is fixed.:))
Basically what I have done I restart whole process. After deleting current file (my scriptos.js) and deleteing eneque from function.php. So I started over.
1. enequeue my file inside function.php following this codefunction wpb_adding_scripts() { wp_enqueue_script('mujscript',get_template_directory_uri().'/myscript.js',array('jquery'), null, false); } add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts');2.creating my new js.file which I am reffering in enequeue line. myscript.js
3.setting authorization rights to this file. In my case I use total commander and changing attributes of my myscript.js file to 644.
4.using trial jquery code inside the myscript.js
jQuery(function($){ $("#button10").click(function(){ $("#button1").fadeToggle(); $("#button2").fadeToggle("slow"); $("#button3").fadeToggle(3000); }); });$ sign in wordpress for jquery can not be as defining jquery. It is just different typo in wordpress
Everything should work right now, if not for future problems for newbies like me , using Developement tools in google chrome(f12) help you analyze problem more efficiently. Thanks everyone for your help. 🙂
Forum: Developing with WordPress
In reply to: Problem loading jQuery script from custom file in WordPressSo I clear the cache from browser, from wordpress (through WP cache plugin), and I even try to clear content of my script file (myscriptos.js) and it still showing the same error. I only did not clear cache of server at least I do not know how? Thank you 🙂 Yes and as a newbie it is a trap next to trap, but it is way of learning to disarm these traps 😀
Thank you for answer and for your help David. I started this problem here https://wordpress.org/support/topic/roblem-loading-jquery-script-from-custom-file-in-wordpress/
And currently I am at: I enequed my custom script file (myscriptos.js) but script itself does not work,and in console it says “Uncaught TypeError: $ is not a function
at myscriptos.js?ver=1.0:1”I tried to change the $dollar signs with different style (with your included) but the error is still the same. (I think it will be something with the versions of Jquery). So I am stuck right now.
Forum: Developing with WordPress
In reply to: Problem loading jQuery script from custom file in WordPressSo this console error brought me to search for what is this console ,how can I use it etc. (very handy tool).Thank you very much for that. So I figured out through certains forums
https://www.hostinger.com/tutorials/what-is-403-forbidden-error-and-how-to-fix-it
that I had to change right to my “myscriptos.js” file. I changed rights to this file (by changing atttributes in TotalCommander through FTP server straight to my server provider of my site from 640 to 644). Fixed that.And after It gave me this error: “Uncaught TypeError: $ is not a function
at myscriptos.js?ver=1.0:1” so through searching I again figured out that typo of jquery in WordPress has to be slightly differenthttps://wordpress.stackexchange.com/questions/2895/not-defined-using-jquery-in-wordpress
So I changed my current jqery script to
jquery(document).ready(function($){ $("#button0").click(function(){ $("#button1").fadeToggle(); $("#button2").fadeToggle("slow"); $("#button3").fadeToggle(3000); }); });but it gives me the same error so i changed again for
jquery(document).ready(function(){ jquery("#button0").click(function(){ jquery("#button1").fadeToggle(); jquery("#button2").fadeToggle("slow"); jquery("#button3").fadeToggle(3000); }); });But still the same. Basically this jquery script I have found here
https://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_fadetoggleSo I am stuck again but we are getting there I feel it. 🙂
- This reply was modified 6 years, 5 months ago by adinaparaglide.
- This reply was modified 6 years, 5 months ago by adinaparaglide.
Forum: Developing with WordPress
In reply to: Problem loading jQuery script from custom file in WordPressThanks and the page I am having my tries on http://travelerky.cz/tryingmyfirstjqueryonwp/?preview=true&fbclid=IwAR12x1CO4BRqNjDEXt7Y2pl1qux3hhroU6qIWcCb6QAitjMhewPhstFNuaU
Forum: Developing with WordPress
In reply to: Problem loading jQuery script from custom file in WordPresscode for enqueueing script is:
function wpb_adding_scripts() { wp_register_script('mujscript', get_template_directory_uri() . '/myscriptos.js', array('jquery'),'1.0', false); wp_enqueue_script('mujscript'); } add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' )I also tried delete the wp_register_script line, like this :
function wpb_adding_scripts() { wp_enqueue_script('mujscript', get_template_directory_uri() . '/myscriptos.js', array('jquery'),'1.0', false); } add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' );and code for script on the myscriptos.js file is:
$(document).ready(function(){ $("#button0").click(function(){ $("#button1").fadeToggle(); $("#button2").fadeToggle("slow"); $("#button3").fadeToggle(3000); }); });But it does not seem to work and regarding the link you sent,it is not working.
Thank you for helping me:)- This reply was modified 6 years, 5 months ago by adinaparaglide.
- This reply was modified 6 years, 5 months ago by adinaparaglide.
Forum: Developing with WordPress
In reply to: Problem loading jQuery script from custom file in WordPressI mean I did the wp_enqueue_script before I came here:D But yeah It did not solve my problem but it was helpful I post it in topic you adviced me(for themes). 🙂
Forum: Developing with WordPress
In reply to: Problem loading jQuery script from custom file in WordPressThank you for advice I will try to ask there, and thx for the tip, I think I did wp_enqueue_script with the help of the topic you send me. :