Revision 31bc4729

b/snf-cyclades-app/synnefo/ui/static/snf/js/models.js
135 135
            var store, key, attr_name;
136 136
            store = synnefo.storage[params[0]];
137 137
            key = params[1];
138
            attr_resolver = params[2];
139
            if (!attr_resolver) {
140
              attr_resolver = function(model, attr) {
141
                return model.get(attr);
142
              }
143
            }
138 144
            attr_name = attr;
139 145
          
140 146
            var resolve_related_instance = function(storage, attr_name, val) {
......
165 171
                    self.trigger("change:" + attr_name, obj);
166 172
                    clearInterval(retry);
167 173
                  }
168
                }, 10);
174
                }, 500);
169 175
              }
170 176
            }
177
            
178
            var self = this;
179
            this.bind('change:' + attr, function(model) {
180
              resolve_related_instance.call(model, store, key, attr_resolver(model, attr));
181
            }, this);
171 182

  
172
            this.bind('change:' + attr, function() {
173
              resolve_related_instance.call(this, store, key, this.get(attr))
174
            });
175

  
176
            this.bind('add', function() {
177
              resolve_related_instance.call(this, store, key, this.get(attr))
178
            });
183
            this.bind('add', function(model) {
184
              resolve_related_instance.call(model, store, key, attr_resolver(model, attr));
185
            }, this);
186
            resolve_related_instance.call(this, store, key, attr_resolver(this, attr));
179 187
          }, this);
180 188
        },
181 189
        

Also available in: Unified diff