• Resolved florianw7

    (@florianw7)


    Hi! I have three separate code snippets which execute the same jQuery code, but are using different classes and IDs.

    I have this weird behaviour, when I deactivate the first code snippet, only the two others work and if I activate it again only the first code snippet works. I tried playing around with the priorities and got it to work (all three working) at some point, but now it’s the same behaviour as desrcibed above again.

    I really don’t understand why it doesnt execute the jQuery code from all three snippets.

    Really looking forward to your replys,
    Florian

Viewing 12 replies - 1 through 12 (of 12 total)
  • I assume that you have added code by using wp_head() hook.
    Have you looked the source code that all exists.
    Code Snippet doesn’t thoroughly check the syntax of JavaScript.
    Code Snippet in such doesn’t execute any JavaScript code. It just generates is.
    If some generated JavaScript does not exist, have you activated all related snippets?
    If all exist, this is not a Code Snippet issue at all except that setting priorities it affects the order of JavaScripts.

    Thread Starter florianw7

    (@florianw7)

    Hi, thanks for your reply!

    Yes I’m using “add_action(‘wp_head’, function() { ?>
    I’m not quite sure what you mean with “looking at the source code”.
    All required code snippets are activated.

    “looking at the source code”.

    You can see the generated code by looking the source code between HEAD tags. If all JavaScript is there and script tags are in correct order, this is not a Code Snippet issue.

    You should check JavaScript and CSS by copying the code to some editor, which checks the validity of JS and CSS.

    Code Snippet checks from JS just that some marks have pairs ( [],(),{},”,”” ). It checks them from JS quite reliable.

    Concering CSS it works unreliable and can’t check properly { + }. That can also cause, that { + } are marked sometimes invalid also for PHP code. Fortunately Code Snippet doesn’t accept invalid PHP – BUT it saves temporary invalid PHP, which might crash your site! Don’t create backend snippets, if you don’t have checked the snippet elsewhere!

    • This reply was modified 4 years, 10 months ago by tapiohuuhaa.
    Thread Starter florianw7

    (@florianw7)

    Just checked it out chrome inspect mode. It shows all the required code in the right order in between the <head> tag.

    Also checked the code out in Visual Studio Code, it shows no syntax errors!

    Really beginning to think that it’s not a code snippets issue.

    Code Snippet has been run by server.
    JavaScript will be run by the browser. Maybe you have duplicate function definitions.

    BTW. Vivaldi is more versatile browser than Chrome. It use the same “engine” as Chrome, but you can tile window into several parts and you have additional sidebar on the left, where is notebook and possibility to add some special pages. I use 2-3 windows side by side (temporary sidebar and two tiled windows side by side, where left I edit the page and right I see, how it looks like). Because it shows like Chrome, I don’t use Chrome at all. Chrome is for Vivaldi just a kind of platform, which Vivald has been build more versatile interface.

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi @florianw7,

    One thing I can think of is that perhaps the jQuery library is not loading as expected.

    What method are you using to load jQuery on the front-end?

    And are you writing your code in no conflict mode? i.e. using jQuery instead of $?

    Thread Starter florianw7

    (@florianw7)

    Hi @bungeshea,

    Can you pls clarify “What method are you using to load jQuery on the-front?” a bit more for me?

    I’ve been using $, will try it with “jQuery” when I’m back at my computer!

    • This reply was modified 4 years, 10 months ago by florianw7.
    Thread Starter florianw7

    (@florianw7)

    I tried it now in no conflict mode, but it’s not working / same behaviour as before.

    @bungeshea would you be so kind and check it out for yourself, if you have the time? I would share the login details with you.

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi florianw7,

    You will also need to make sure the jQuery library itself is loaded on the page before your scripts execute. Can you see it linked if you view the page source?

    WordPress does not load jQuery on the front-end of your site by default.

    Thread Starter florianw7

    (@florianw7)

    Hi Shea

    yes it is linked, I see this in my source code:

    <script type="text/javascript" src="https://formlos.at/wp-includes/js/jquery/jquery.js"></script>

    As I described above, half of my code is working if I disable some code snippets. I also checked it several times with visual studio code for syntax errors.

    It may be conflicting with another plugin or something else on my site.

    • This reply was modified 4 years, 10 months ago by florianw7.
    Thread Starter florianw7

    (@florianw7)

    Issue resolved, it actually was a typo.

    Thank you guys anway for your help!

    • This reply was modified 4 years, 10 months ago by florianw7.
    Plugin Author Shea Bunge

    (@bungeshea)

    Glad to hear it’s working now!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘jQery code not executing’ is closed to new replies.