• Resolved perleone

    (@perleone)


    hello,

    I use favoriteposts Plugin for a little notepad feature on my site. I developed a simple form with it on a subdomain. When I was happy with the result, I installed the favoriteposts plugin on the real page. But then I realized that the favoriteposts buttons dont work on this wordpress installation. (I can see the Button at the end of each post, but when I click it, nothing happens, no Post Ajax request!). On my subdomain which is a copy of the real site, everything works fine.

    I checked the site with firebug and run into a bunch of Errors. I think one or even more of these errors could be responsible for my problem with favoriteposts. Am I right here?

    ReferenceError: jQuery is not defined
    ReferenceError: jQuery is not defined
    TypeError: e is not a function
    ReferenceError: Backbone is not defined
    ReferenceError: _ is not defined

    But how can I fix it? How can I define jQuery, Backbone and co to avoid these Errors, Why they even occur?

    This is the link to my Site

    Thanks for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter perleone

    (@perleone)

    I solved the Problem but just in a deprecitated way. The trouble is caused by the jQuery Error. But I am not able to enqueue jQuery via

    add_action( 'wp_print_scripts', 'add_my_scripts', 100 );
    function add_my_scripts() {
    if ( !is_admin() ) {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', ( 'https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js' ), false, null, true );
    wp_enqueue_script( 'jquery' );
    } }
    add_action('init', 'add_my_scripts');

    or

    add_action( 'wp_print_scripts', 'add_my_scripts', 100 );
    function add_my_scripts() {
    if ( !is_admin() ) {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', ( 'https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js' ), false, null, false );
    wp_enqueue_script( 'jquery' );
    } }
    add_action('init', 'add_my_scripts');

    when I look at my sourcecode I can see jQuery is embedded in the head, like in the codeblock

    <script type='text/javascript' defer='defer' src='https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js'></script>

    but I run into the same jQuery Issue anyway.

    Only when I insert my jQuery through the header.php, like its not recommended I solved my Problem, no Errors, FavoritePosts works.

    But I want to do it the right way, Can anyone help me please

    Thanks!

    Thread Starter perleone

    (@perleone)

    Problem solved.

    It occured because of the ‘defer’ in the script tag. This was caused by the Plugin
    Async JavaScript. It was possible to exclude jQuery.js from the Async Plugin an then everything worked fine.

    Maybe this can help someone in the future.
    Thanks anyway

    perleone

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: FavoritePosts] Button does nothing, ReferenceError: jQuery not defined’ is closed to new replies.