1

UPDATE: Changing my theme seems to have fixed the problem - but I'm not sure how to fix the original theme. Any advice on that issue is still welcome!

I'm seeing symptoms identical to this question: Backbone JS error with 4.6.4 on WP messing up contribution page set up

Pages using Backbone - particularly the "Include Profile" contribution configuration page - are broken, and the JS console says:

TypeError: Backbone.Marionette is undefined
TypeError: Backbone.CollectionSubset is not a constructor

However, the issue seems to be different than other folks experiencing it. Here's what I've tried so far (including all at once):

  • Disabling all WP plugins except CiviCRM.
  • Disabling Summary Fields (the only CiviCRM extension in use).
  • Clearing cache, deleting templates_c.

What else can I look for regarding this Backbone error? I assume it's a collision with WordPress's Backbone, but I don't know enough about Wordpress to troubleshoot that.

2 Answers 2

3

I think that when I had this it was caused by a theme loading a newer version of Backbone. Can you dequeue the script in that theme's functions.php? And try queuing the Civi version direct? Admittedly a bit of a long shot.

4
  • yes, I'd reached similar conclusions as well - and tracked it down to Backbone being enqueued by the theme. I'm currently creating a child theme so that I can address this, and based on your help, I'll use wp_dequeue_script() to do so. As a WP novice, I have a question though: Is there a good way to only call this dequeueing function if we're on a CiviCRM page? Commented Jan 27, 2016 at 21:53
  • @JonG did you get this worked out? I THINK I worked out a tiny piece of the actual solution, but it's only half the problem and a tenth or less of the solution. See: civicrm.stackexchange.com/questions/3711/…
    – G H
    Commented Apr 21, 2016 at 12:33
  • @GH Yes, I got this worked out - see the answer I posted to this question. Commented Apr 21, 2016 at 15:20
  • @JonG, I did see your other answer, unfortunately the Salient theme doesn't have exactly the same problem. I was hoping that you had found the code for this workaround. I'll ping Andrew as I'm having trouble getting my mind wrapped around the specifics here.
    – G H
    Commented May 20, 2016 at 19:41
2

OK, I've got this working - I didn't use Andrew West's technique above, but I still upvoted the answer as helpful.

The theme had this code in one of its includes:

if ( ! function_exists( 'optionsframework_media_scripts' ) ) : 

add_action( 'admin_enqueue_scripts', 'optionsframework_media_scripts' );

function optionsframework_media_scripts(){
  if ( function_exists( 'wp_enqueue_media' ) ) 
    wp_enqueue_media();
  wp_register_script( 'of-media-uploader', OPTIONS_FRAMEWORK_DIRECTORY .'js/media-uploader.js', array( 'jquery' ) );
  wp_enqueue_script( 'of-media-uploader' );
  wp_localize_script( 'of-media-uploader', 'optionsframework_l10n', array(
    'upload' => __( 'Upload', 'organizedthemes' ),
    'remove' => __( 'Remove', 'organizedthemes' )
  ) );
}

endif;

This was loading Backbone. It also seems to be extraneous; the media uploader seems to work fine with this function commented out.

So I created a child theme, and in the functions.php file in my child theme, I added this code:

//put in a blank function here to override loading this function in the parent theme.
function optionsframework_media_scripts(){}

This worked great! Ideally I'd like to copy the code from the child theme and add some conditional logic to say, "Only enqueue these scripts on a non-CiviCRM page" - but unfortunately that's beyond my Wordpress knowledge.

1
  • 1
    For a quick and easy hack I'd just check the URL for the civi basepage. Otherwise I think you could check to see if Civi has been initialized: ie "if (civicrm_initialize())" - but may want to test this one as I'm not 100% sure Civi would have initialized by that point in the theme processing. Commented Jan 28, 2016 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.