[Resolved] Where do i find the document ready block file to ad js?

Home Forums Support [Resolved] Where do i find the document ready block file to ad js?

Home Forums Support Where do i find the document ready block file to ad js?

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #759596
    Carsten

    Hi there, I have been looking in the js folder for the the document ready block in GB to add some js code, but I can’t locate it.

    Put this line inside the document ready block of your theme’s js file

    Regards
    Carsten

    #759677
    David
    Staff
    Customer Support

    Hi there,

    what code are you trying to add? If it’s a jquery you can just wrap it like so:

    jQuery( document ).ready( function( $ ) {
        script in here
    } );

    And use the Hook Element – WP Footer Hook:

    https://docs.generatepress.com/article/hooks-element-overview/

    #759994
    Carsten

    Hi David, yes it is a jQuery, and I had tried to put it in a custom hook, but it doesn’t kick in.
    I have posted this issue before but wanted to try another approach, copying the code directly in a js file, because the custom hook option in GP shows no effect.

    <script type=”text/javascript”>
    jQuery(document).ready(function() {
    jQuery(‘#send_message_form’).submit( function() {
    jQuery(‘#subject’).val(“Some message subject”);
    });
    });
    </script>

    Ps. I do not receive email on replies, despite this option is checked?

    #760080
    David
    Staff
    Customer Support

    Can you link me to the article where it explains adding this code?

    #760081
    Carsten

    Here it is

    #760082
    Carsten
    #760085
    David
    Staff
    Customer Support

    Can you add the script to the WP_Footer hook and set the display rules to the entire site?

    #760099
    Carsten

    No difference, could you please check if the wrapping is correct?

    View post on imgur.com

    #760210
    David
    Staff
    Customer Support

    The only thing that looks a little odd are the single and double quotes. Remove them and replace them manually.

    #761024
    Carsten

    Hi David, just a status update, as it turns out, the jQuery I tried to add, only works with the Buddypress Legacy template, not Nouveau. So no wonder I couldn’t make it work.

    Thanks for your efforts

    Regards
    Carsten

    #761055
    David
    Staff
    Customer Support

    Haha – awesome – glad you found out the reason 🙂

    #761218
    Carsten

    Just a quick question, I am going to insert code into the head section of my site, is the Header element the right place for Header Scripts like this (for PWA icon support on iOS)?

    <!– place this in a head section –>
    <link rel=”apple-touch-icon” href=”touch-icon-iphone.png”>
    <link rel=”apple-touch-icon” sizes=”152×152″ href=”touch-icon-ipad.png”>
    <link rel=”apple-touch-icon” sizes=”180×180″ href=”touch-icon-iphone-retina.png”>
    <link rel=”apple-touch-icon” sizes=”167×167″ href=”touch-icon-ipad-retina.png”>

    Regards
    Carsten

    #761223
    David
    Staff
    Customer Support

    The Hook Element is the right place for adding scripts / meta etc.
    Select the wp_head hook in the element.

    #761224
    Carsten

    Hi Dave thanks for your quick reply, I had choose Header element instead of Hook > wp_head…

    #761230
    David
    Staff
    Customer Support

    Some more info on the hooks element can be found here, in case you need it:

    https://docs.generatepress.com/article/hooks-element-overview/

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.