1

I'm having issues with the following code every since I added barbs.js (a page transition library) to my site.

Basically I have a js file that controls the transition and ajax. The following code exists within an event that triggers when the page transition has completed. The event works as I've tested it. The son array exists as I have rendered it at the bottom of the page and content is there. My javascript say:

SyntaxError: Unexpected token '{'. Expected a property name.

For the following code:

var jsonMeta = {{ jsonMeta|json_encode|raw }};

This used to work work but doesn't anymore. The full code is:

var Contentpage = Barba.BaseView.extend({
  namespace: 'contentpage',

    onEnter: function() {
       $('#navigation').removeClass('invert-nav-bar');
  },

  onEnterCompleted: function() {
       Barba.Dispatcher.on('transitionCompleted', function(currentStatus) {
        var jsonMeta = {{ jsonMeta|json_encode|raw }};
        $('head').find('title').text(jsonMeta.meta.title);
        $.each(jsonMeta.meta.link, function(k, v){
            $.each(v, function(kk, vv){
                $('head').find('link[' + k + '="' + kk + '"]').attr('href', vv);
            });
        });

        $.each(jsonMeta.meta.meta, function(k, v){
            $.each(v, function(kk, vv){
                $('meta[' + k + '="' + kk + '"]').attr('content', vv);
            });
        });
        });


  }


});

Contentpage.init();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.