Сохранить this в callback?

Рейтинг: 1Ответов: 1Опубликовано: 04.11.2014

Есть коллбэк beforeLoad FancyBox. В нем другой коллбэк getVideo:

beforeLoad: function () {
            var id = $(this.element).attr("id");
            getVideo(id, function(response){
                this.title = this.title ? this.title + 'mmm' : 'kkk';
                this.width = $(this.element).data("width");
                this.height = $(this.element).data("height");
            });
        },

Как сделать, чтобы объекты this.title, this.width, this.height, this.element были доступны в getVideo callback?

Ответы

▲ 2Принят

Use the bind, Luke!