Several aviary feathers

I have a problem integrating the Aviary Pen. In my javascript, I need to use Feathers as follows:

// 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();
  }
});

Then i call two feather

featherProductEditor.launch({ ....

and

featherContentBlockEditor.launch({ ....

but the only onSave * callback called : is the second option featherContentBlockEditor "var

Why? How can i solve this?

+4
source share
3 answers

For your first question, why is only the second called onSave?

Inside, the Aviary Web SDK stores the pen configuration in AV.launchData, and AVis an alias of the global variable Aviary. This is a snippet of code from a function 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 .

+3

?

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' .

+1

Aviary , , :

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

Source: https://habr.com/ru/post/1543592/


All Articles