Google Picker API - how to load a picker on demand

老子叫甜甜 提交于 2021-02-08 11:14:08

问题


I want to use the google picker api . The example shows the picker being loaded when the page loads, and I want a picker to be loaded when I click on something, but it doesn't seem to work properly in that situation. So the working example is:

<script>

google.setOnLoadCallback(createImgPicker);
google.load('picker', '1');

function createImgPicker(){
  //CREATE HERE
}

</script>

but what I want is something like:

$('#button').on('click',function(){
  google.setOnLoadCallback(createImgPicker);
  google.load('picker', '1');
});

How do I accomplish this?


回答1:


This worked:

$('#button').on('click',function(){

  google.load('picker', '1', {"callback": function (e) {

    //do stuff

  }});
});


来源:https://stackoverflow.com/questions/17304344/google-picker-api-how-to-load-a-picker-on-demand

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!