Pierre Cangem's
Pierre Cangem's

Reputation: 23

FB.UI callback with scopes on Backbone

var obj={
         method: 'feed',

         name: 'Je viens de créer son premier domaine : "' + this.model.attributes.name + '"',
         caption: 'Entrez dans l\'univers du vin avec Vinoga',
         description: (
            'Ayez un domaine plus grand, plus beau ou plus prestigieux que vos amis. Challengez vos amis à travers de nombreux mini-jeux et rendez-leur visite '
         ),
         link: 'http://www.vinoga.com',
         picture: 'https://twimg0-a.akamaihd.net/profile_images/3095682321/79e5bb5014d6b118b08c5b11bd2a81e8.jpeg'
        };

        function callback(response)
        {
            this.model.setActivation(); // HERE 
            alert('toto');
        }
            FB.ui(obj, callback);
       },

I got an error about this.model.setActivation is undefined ... Do you have any idea how to solve this?

Thanks in Advance Pierre

Upvotes: 0

Views: 140

Answers (1)

Paul Hoenecke
Paul Hoenecke

Reputation: 5060

You can use underscore's bind helper to set the context for the callback.

FB.ui(obj, _.bind(callback, this));

Upvotes: 1

Related Questions