首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多航羽毛

多航羽毛
EN

Stack Overflow用户
提问于 2014-06-06 16:43:21
回答 3查看 1.5K关注 0票数 4

我有个关于“鸟羽”整合的问题。在我的javascript中,我需要使用这样的羽毛:

代码语言: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();
  }
});

然后我叫那两个羽毛

代码语言:javascript
复制
featherProductEditor.launch({ ....

代码语言:javascript
复制
featherContentBlockEditor.launch({ ....

但是唯一被调用的"onSave*“回调是第二个变量

为什么?我怎么才能解决这个问题?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-06-19 03:20:13

关于您的第一个问题,为什么只调用第二个onSave ?

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

代码语言:javascript
复制
AV.Feather = function (config) {
    ...
    AV.launchData = AV.util.extend(AV.baseConfig, config);
    ...
}

因此,这意味着featherContentBlockEditor的配置将覆盖featherProductEditor的配置。

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

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

不,你必须侵入SDK。这就是Aviary的工作方式,每个页面只定义一个Aviary.Feather实例。

票数 3
EN

Stack Overflow用户

发布于 2015-09-11 15:13:53

你怎么能解决它?

您可以使用imageID来标识生成onSave事件的Aviary实例。

代码语言:javascript
复制
  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'作为发布信息以获取您的产品形象。

票数 1
EN

Stack Overflow用户

发布于 2014-10-30 18:55:46

您只能在给定的页面上拥有Aviary编辑器的一个实例,但是您可以通过调用:

代码语言:javascript
复制
  editor.close(true); // passing true forces an immediate close without triggering shutdown animation
  editor.launch({ image: new_id, url: new_url });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24086869

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档