Changeset 100

Show
Ignore:
Timestamp:
04/25/08 21:59:45 (7 months ago)
Author:
nickstenning
Message:

Remove well-intentioned but idiotic Model#get method. Pass respObject into callbacks.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/microfacts/public/app/controllers/factlet_info_controller.js

    r86 r100  
    1616    }, 
    1717    updateViewFor: function (id) { 
    18         Factlet.entityGet(id).callback(function () { 
    19             var html = this.renderView('factlet/factlet', Factlet.get(id)); 
     18        Factlet.entityGet(id).callback(function (factlet) { 
     19            var html = this.renderView('factlet/factlet', factlet); 
    2020            this.element.set('html', html); 
    2121        }, this).send(); 
  • trunk/microfacts/public/app/lib/model.js

    r86 r100  
    1313                                              responseObject, 
    1414                                              responseText); 
    15             fn.bind(binding)(); 
     15            fn.bind(binding)(responseObject); 
    1616        }); 
    1717        this.addEvent('onSuccess', function (responseObject, responseText) { 
     
    2020                                              responseObject, 
    2121                                              responseText); 
    22             fn.bind(binding)(); 
     22            fn.bind(binding)(responseObject); 
    2323        }); 
     24        return this; 
     25    } 
     26}); 
     27 
     28CallbackWrapper = new Class({ 
     29    initialize: function (object) { 
     30        this.object = object; 
     31    }, 
     32    callback: function(fn, binding) { 
     33        this.fn = fn.bind(binding); 
     34        return this; 
     35    }, 
     36    send: function () { 
     37        this.fn(this.object); 
    2438        return this; 
    2539    } 
     
    4458        this.entities = new Hash(); 
    4559        this.addEvents(this.options.events); 
    46     }, 
    47     get: function (id) { 
    48         return this.entities.get(id); 
    4960    }, 
    5061    registerGet: function () { 
  • trunk/microfacts/public/app/views/thread/factlet-list.ejs

    r88 r100  
    11<% if (c.factlets.length > 0) { %> 
    22  <div class="thread-factlets"> 
    3  
    43  <% $each(c.factlets, function (factlet, idx) { %> 
    5     <% console.log(factlet); %> 
    64    <div id="factlet-<%= factlet.id %>" class="factlet"> 
    75      <h3 class="factlet-title"><%= factlet.title %></h3>