Because the 'this' being used was for the wrong scope
data-interchange-last-path is not set. This can lead to making multiple
requests for the same content unnecessarily.
return trigger(el[0].src);
}
- var last_path = el.data(this.data_attr + '-last-path');
+ var last_path = el.data(this.data_attr + '-last-path'),
+ self = this;
if (last_path == path) return;
return $.get(path, function (response) {
el.html(response);
- el.data(this.data_attr + '-last-path', path);
+ el.data(self.data_attr + '-last-path', path);
trigger();
});
});
});
}));
+
+ describe('setting data-interchange-last-path', function() {
+ beforeEach(function() {
+ document.body.innerHTML = __html__['spec/interchange/basic.html'];
+ });
+
+ it('should set data-interchange-last-path on element when replace occurs', function() {
+ Foundation.libs.interchange.update_nodes();
+ Foundation.libs.interchange.resize();
+
+ expect($('div[data-interchange]').data('data-interchange-last-path')).toMatch(/.+html$/)
+ });
+ });
});