Вопрос

I'm passing data to closure template(soy) via Javascript (json) but getting the about error in firebug.

// Simple html that starts the whole process
<html lang="en">
  <head>
  <title>Gigya Social Demo  - getContacs</title>
  <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jquery.lightbox_me.js"></script>
    <!-- add the soy js here-->
    <script type="text/javascript" src="emailcontacts.js"></script>
    <script type="text/javascript" src="invite_emailcontacts_view.js"></script>

    <script type="text/javascript">
      function openLightbox() {
          var data = [{"provider":"Yahoo","firstName":"myname","lastName":"mysurname","nickname":"mynick","email":"email@hotmail.com","photoURL":"http://l.yimg.com/dh/ap/social/profile/profile_b10.png"}];
          var invite = new InviteContactEmailView();
          console.log(invite);
          invite.open(data);
          return this;
        }
    </script>
    <style>
      #contactsOverlay {
        -moz-border-radius: 6px;
        background: #eef2f7;
        -webkit-border-radius: 6px;
        border: 1px solid #536376;
        -webkit-box-shadow: rgba(0,0,0,.6) 0px 2px 12px;
        -moz-box-shadow:  rgba(0,0,0,.6) 0px 2px 12px;;
        padding: 14px 22px;
        width: 400px;
        position: relative;
        display: none;
    }
  </head>
  <body onLoad="openLightbox()">

    <div id="contactsOverlay">
  </body>
</html>

// soy invoker in file invite_emailcontacts_view.js
function InviteContactEmailView() {
  this.template = {}; 
  this.template.element = $('#contactsOverlay');

  this.elementSelector = this.template.element;
}

InviteContactEmailView.prototype.open = function(contacts) {
    this.elementSelector.lightbox_me({destroyOnClose: true, centered: true, onLoad: testme(this.elementSelector, contacts) }); 
    return this;
};

var testme = function(ele, contacts) {
  ele.append(jive.invite.emailcontacts.create(contacts));
  $('fieldset div').bind('click', function() {
    var checkbox = $(this).find(':checkbox');

    checkbox.attr('checked', !checkbox.attr('checked'));
  }); 
}


// soy template (on compile resides in file: emailcontacts.js)
{namespace jive.invite.emailcontacts}

/**
*   @param contacts
*   @depends path=/var/www/statics/js/invite_emailcontacts_view.js
**/
{template .create} 
    {foreach $contact in $contacts}
        <fieldset>
            <div>
                <div class="data"></div>
                <input type="checkbox" id="checkbox">
            </div>
        </fieldset>
    {/foreach}
{/template}

Any kind of help is greatly appreciated.

REgards

Это было полезно?

Решение

Where is the compiled template? Putting a breakpoint in there will tell you more. I suspect you are not passing a hash to the template when you invoke it with a key contacts. Basically the template you declared should get a data set which looks something like this:

{contacts: [....]}

this obviously assumes you are not compiling in advanced mode.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top