jQuery Backstretch is nog a function

Hi,

during beta-testing I discovered an issue with the JS snippet for the scroll-to-top anchor being loaded in such a way that JS Minificators, like some caching-plugins, would not handle it correctly (loading the snippet before jQuery has been loaded etc).
Looks like I just discovered the same issue again, but then with the backstretch function that’s used when a global background image is set.

The error looks like this:
Uncaught TypeError: jQuery.backstretch is not a function
at (index):279

@alexander looks like this is an identical issue as the one that occured with the scrollToBottom anchor script. If so, could this be considered for fixing in the upcoming 2.0.3?

Thanks for pointing this out. For the next release I’ve wrapped it in jQuery.ready so it should wait until the plugin is available.

That’s great news, thanks!
I’d be happy to test if that indeed fixes the solution. Would it be an idea to share the updated file/code in a private note? I’ll overwrite that manually in the current version and share my findings.

Hi there,

You can directly edit it through \framework\functions\global\admin\customizer\output.php, and you can change it to something like this.

function x_customizer_output_js() {

  $x_custom_scripts                     = x_get_option( 'x_custom_scripts' );
  $entry_id                             = get_the_ID();
  $x_entry_bg_image_full                = get_post_meta( $entry_id, '_x_entry_bg_image_full', true );
  $x_entry_bg_image_full_fade           = get_post_meta( $entry_id, '_x_entry_bg_image_full_fade', true );
  $x_entry_bg_image_full_duration       = get_post_meta( $entry_id, '_x_entry_bg_image_full_duration', true );
  $x_design_bg_image_full               = x_get_option( 'x_design_bg_image_full' );
  $x_design_bg_image_full_fade          = x_get_option( 'x_design_bg_image_full_fade' );

  ?>

  <?php if ( $x_custom_scripts ) : ?>

    <script id="x-customizer-js">
      <?php echo $x_custom_scripts; ?>
    </script>

  <?php endif; ?>

  <?php if ( $x_entry_bg_image_full && is_singular() ) : ?>

    <?php
    $page_bg_images_output = '';
    $page_bg_images        = explode( ',', $x_entry_bg_image_full );
    foreach ( $page_bg_images as $page_bg_image ) {
      $page_bg_images_output .= '"' . $page_bg_image . '", ';
    }
    $page_bg_images_output = trim( $page_bg_images_output, ', ' );
    ?>

    <script>jQuery( document ).ready( function($){ $.backstretch([<?php echo $page_bg_images_output; ?>], {duration: <?php echo $x_entry_bg_image_full_duration; ?>, fade: <?php echo $x_entry_bg_image_full_fade; ?>}); });</script>

  <?php elseif ( $x_design_bg_image_full ) : ?>

    <script>jQuery( document ).ready( function($){ $.backstretch(['<?php echo x_make_protocol_relative( $x_design_bg_image_full ); ?>'], {fade: <?php echo $x_design_bg_image_full_fade; ?>}); });</script>

  <?php endif;

}

Thanks!

I can confirm this one being fixed in the latest 0.4 release. Awesome work guys, thanks!

Great! Thanks for confirming with us.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.