Javascript 多羽鸟

Javascript 多羽鸟,javascript,aviary,Javascript,Aviary,我有一个关于航空羽毛的整合的问题。 在我的javascript中,我需要使用如下特征: // Aviary init var featherProductEditor = new Aviary.Feather({ apiKey: 'myapykey', apiVersion: 3, theme: 'dark', tools: 'all', appendTo: '', onSave: function(imageID, newURL) { // Do things

我有一个关于航空羽毛的整合的问题。 在我的javascript中,我需要使用如下特征:

// Aviary init
var featherProductEditor = new Aviary.Feather({
  apiKey: 'myapykey',
  apiVersion: 3,
  theme: 'dark',
  tools: 'all',
  appendTo: '',
  onSave: function(imageID, newURL) {
    // Do things for featherProductEditor
    console.log('featherProductEditor');
    // Close the editor
    featherProductEditor.close();
  }
});

// Aviary init
var featherContentBlockEditor = new Aviary.Feather({
  apiKey: 'myapykey',
  apiVersion: 3,
  theme: 'light',
  tools: 'all',
  appendTo: '',
  onSave: function(imageID, newURL) {
    // Do things for featherContentBlockEditor
    console.log('featherContentBlockEditor');
    // Close the editor
    featherContentBlockEditor.close();
  }
});
那我就叫这两根羽毛

featherProductEditor.launch({ ....

但是唯一调用的“onSave*:”回调是“featherContentBlockEditor”变量的第二个


为什么??我如何解决这个问题?

对于第一个问题,为什么只调用第二个
onSave

在内部,Aviary Web SDK将羽毛配置存储在
AV.launchData
中,并且
AV
Aviary
全局变量的别名。这是来自
Aviary.Feather
函数的代码片段:

AV.Feather = function (config) {
    ...
    AV.launchData = AV.util.extend(AV.baseConfig, config);
    ...
}
因此,这意味着
featherContentBlockEditor
的配置将覆盖
featherProductEditor
的配置

您可以通过在创建每个羽毛后添加
AV.launchData.onSave()
来验证这一点

关于第二个问题,我如何解决这个问题?


不,你不能不侵入SDK。这就是Aviary Web SDK的工作原理,每页只定义一个Aviary.Feather的实例。

给定页面上只能有一个Aviary editor实例,但可以通过调用:

  editor.close(true); // passing true forces an immediate close without triggering shutdown animation
  editor.launch({ image: new_id, url: new_url });

你如何解决这个问题?

您可以使用
imageID
确定哪个Aviary实例产生了onSave事件

  onSave: function(imageID, newURL) {
    if(imageID === 'productImg') {
      // Do things for featherFeatureEditor
      console.log('featherProductEditor');
    } else {
      // Do things for featherContentBlockEditor
      console.log('featherContentBlockEditor');
    }
    // Close the editor
    featherContentBlockEditor.close();
  }

使用
image:'productImg'
进行产品映像的发布配置。

您是否尝试过调用
onError
onReady
回调而不是
onSave
?是的,我已经尝试过了,onError不会返回任何内容。onReady总是调用第二个feather initialized您在
x.launch({…
)中提供了什么?因为该对象是一个配置覆盖,所以最好知道其中有什么。
  onSave: function(imageID, newURL) {
    if(imageID === 'productImg') {
      // Do things for featherFeatureEditor
      console.log('featherProductEditor');
    } else {
      // Do things for featherContentBlockEditor
      console.log('featherContentBlockEditor');
    }
    // Close the editor
    featherContentBlockEditor.close();
  }