whoops, binding func wasn't propagating the return value... not so good...
authorAndrew Sutherland <asutherland@asutherland.org>
Sun, 11 Jan 2009 07:56:23 -0800
changeset 6 d9d6be88da9347b14703f293eecc5c4b631c2c8d
parent 5 66f9fe7b2df5025c5c439a4469b3ad08baf07b01
child 7 8199bc2b97516978eca1b6973869c250196984dc
push id1
push userroot
push dateWed, 08 Apr 2009 01:46:05 +0000
whoops, binding func wasn't propagating the return value... not so good...
client/autocomplete.xml
client/index.xhtml
client/xbl-src.js
--- a/client/autocomplete.xml
+++ b/client/autocomplete.xml
@@ -145,27 +145,29 @@
           height: 32;
           float: left;
         }
       ]]></xbl:style>
     </xbl:resources>
     <xbl:implementation><![CDATA[
       ({
         type: "contact",
-        getType: function() { return this.type; },
+        getType: function() {
+          return this.type;
+        },
         contact: null,
         getContact: function() {
           return this.contact;
         },
         setContact: function(aContact) {
-          this._contact = aContact;
+          this.contact = aContact;
           console.log("setContact", this);
-          this._nName.textContent = this._contact.name;
+          this._nName.textContent = this.contact.name;
           var bestEmail = null;
-          var emailText = this._contact.identities.map(function (identity) {
+          var emailText = this.contact.identities.map(function (identity) {
             if (identity.kind == "email")
               bestEmail = identity.value;
             return identity.value;
           }).join(", ");
           this._nEmails.textContent = emailText;
           if (bestEmail) {
             this._nPicture.setAttribute("src",
               "http://www.gravatar.com/avatar/" + hex_md5(bestEmail) +
--- a/client/index.xhtml
+++ b/client/index.xhtml
@@ -19,18 +19,25 @@
       var autocompleter = document.getElementById("autocomplete");
       console.log("autocompleter", autocompleter);
       autocompleter.addCompleter(ContactCompleter);
       console.log("contact completer registered");
       
       var constraints = document.getElementById("constraints");
       autocompleter.addActionListener(function (item) {
         console.log("!!!Action Listener!!!", item);
-        if (item.getType() == "contact")
-          constraints.addContact(item.getContact());
+        var itemType = item.getType();
+        console.log(".type:", itemType);
+        if (itemType == "contact") {
+          console.log("..contact case");
+          var contact = item.getContact();
+          console.log("contact", contact);
+          constraints.addContact(contact);
+          console.log("added contact", contact);
+        }
         else
           return;
       });
       console.log("constrainer registered");
     }
 
     $(function() {
       window.setTimeout(funkyInit, 1000);
--- a/client/xbl-src.js
+++ b/client/xbl-src.js
@@ -1446,17 +1446,17 @@ cElementXBL.prototype.addBinding	= funct
 
     // The oBinding is roughly the internal object, whereas 'this' gets to be
     //  the external object.
 	var oBinding	= new cBinding;
 
 	// 3) Attach implementation
     function bind(func) {
       return function() {
-        func.apply(oBinding, arguments);
+        return func.apply(oBinding, arguments);
       };
     }
 
 	for (var sMember in oBinding)
 		if (sMember.indexOf("xbl") != 0) {
             // All functions need to be wrapped to dispatch so that they are
             //  calling the method on the inner object, otherwise things get
             //  in a mess 'this'-wise.