Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   Персонализированная кнопка входа google+ (https://javascript.ru/forum/events/55331-personalizirovannaya-knopka-vkhoda-google.html)

autumn 23.04.2015 13:34

Персонализированная кнопка входа google+
 
Здравствуйте
Для создания персонализированной кнопки входа в google+ просто копирую их код отсюда https://developers.google.com/+/web/...ustomize?hl=ru
На данном сайте на кнопку входа назначается событие click, поэтому при нажатии открывается фрейм, а у меня событие не назначается, соответственно, вход в гугл не работает
Пожалуйста, помогите найти причину этого

Приведу на всякий случай скопированный с вышеуказанного сайта код
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css">
  <script src="https://apis.google.com/js/client:platform.js?onload=render" async defer></script>
  <script>
  function render() {
    gapi.signin.render('customBtn', {
      //'callback': 'signinCallback',
      'clientid': '841077041629.apps.googleusercontent.com',
      'cookiepolicy': 'single_host_origin',
      'requestvisibleactions': 'http://schema.org/AddAction',
      'scope': 'https://www.googleapis.com/auth/plus.login'
    });
  }
  </script>
  <style type="text/css">
    #customBtn {
      display: inline-block;
      background: #dd4b39;
      color: white;
      width: 165px;
      border-radius: 5px;
      white-space: nowrap;
    }
    #customBtn:hover {
      background: #e74b37;
      cursor: hand;
    }
    span.label {
      font-weight: bold;
    }
    span.icon {
      background: url('/+/images/branding/btn_red_32.png') transparent 5px 50% no-repeat;
      display: inline-block;
      vertical-align: middle;
      width: 35px;
      height: 35px;
      border-right: #bb3f30 1px solid;
    }
    span.buttonText {
      display: inline-block;
      vertical-align: middle;
      padding-left: 35px;
      padding-right: 35px;
      font-size: 14px;
      font-weight: bold;
      /* Use the Roboto font that is loaded in the <head> */
      font-family: 'Roboto',arial,sans-serif;
    }
  </style>

  <div id="gSignInWrapper">
    <span class="label">Sign in with:</span>
    <div id="customBtn" class="customGPlusSignIn">
      <span class="icon"></span>
      <span class="buttonText">Google</span>
    </div>
  </div>

autumn 23.04.2015 16:42

Все оказалось просто: назначала событие элементу, которого еще не было в DOM-дереве. Теперь все работает.


Часовой пояс GMT +3, время: 21:41.