Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/467.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 加载HeadJS的脚本仅在第二次单击时运行_Javascript_Aviary - Fatal编程技术网

Javascript 加载HeadJS的脚本仅在第二次单击时运行

Javascript 加载HeadJS的脚本仅在第二次单击时运行,javascript,aviary,Javascript,Aviary,加载HeadJS的脚本仅在第二次单击时运行。如何在第一次点击时获得鸟舍发射器 在调用launch函数之前,需要等待插件初始化。您可以使用onLoad事件: var featherEditor = new Aviary.Feather({ apiKey: 12345, apiVersion: 3, onLoad: function() { featherEdi

加载HeadJS的脚本仅在第二次单击时运行。如何在第一次点击时获得鸟舍发射器


在调用
launch
函数之前,需要等待插件初始化。您可以使用
onLoad
事件:

var featherEditor = new Aviary.Feather({
                apiKey: 12345,
                apiVersion: 3,
                onLoad: function() {
                     featherEditor.launch({
                        image: $id,
                        url: $src
                    });
                }                                    
            }); 

在调用
launch
函数之前,需要等待插件初始化。您可以使用
onLoad
事件:

var featherEditor = new Aviary.Feather({
                apiKey: 12345,
                apiVersion: 3,
                onLoad: function() {
                     featherEditor.launch({
                        image: $id,
                        url: $src
                    });
                }                                    
            }); 

回答mikebridge,对于第二次无法打开的情况:

一些黑暗的原因阻止feather被多次实例化。 使用window.globalAviaryFeather保存实例

function launch(url) {
    window.globalAviaryFeather.launch({
        image: "imgId",
        url: url
    })
}

var url = "..."

if (window.globalAviaryFeather) {
    launch(url)

} else {
    window.globalAviaryFeather = new Aviary.Feather({
        ...
        onLoad: function() {
            self.launch(url)
        }
    })
}

回答mikebridge,对于第二次无法打开的情况:

一些黑暗的原因阻止feather被多次实例化。 使用window.globalAviaryFeather保存实例

function launch(url) {
    window.globalAviaryFeather.launch({
        image: "imgId",
        url: url
    })
}

var url = "..."

if (window.globalAviaryFeather) {
    launch(url)

} else {
    window.globalAviaryFeather = new Aviary.Feather({
        ...
        onLoad: function() {
            self.launch(url)
        }
    })
}

我第二次实例化鸟舍时,onLoad没有为我开火。Feather:我第二次实例化鸟舍时,onLoad没有为我开火。Feather: