Permalink
Browse files

List update

  • Loading branch information...
daffl committed Aug 9, 2012
1 parent 99db5ef commit 2825dd653ba4ce9e5085cb832aa4ec799c4c0c2f
Showing with 6 additions and 27 deletions.
  1. +6 −5 list/list.js
  2. +0 −22 list/list_test.js
View
@@ -1,4 +1,4 @@
-steal('jquery', 'can/control', 'can/control/plugin', 'can/view', 'can/observe',
+steal('jquery', 'can/control', 'can/control/plugin', 'can/view', 'can/observe', 'can/view/ejs',
function($) {
can.Control('can.ui.List', {
pluginName : 'list',
@@ -59,17 +59,18 @@ function($) {
return can.$.map(observes, can.proxy(function(observe) {
// Update the mapping from can.Observe unique id to Observe instance
self._cidMap[observe[self.options.cid]] = observe;
- return this._content('view', observe);
+ var op = this.options.view,
+ row = can.isFunction(op) ? op.call(this, observe) : can.view(op, observe);
+ return this._wrapWithTag(row, observe)
}, this));
},
_content : function(name, param) {
if(!this.options[name]) {
return '';
}
- var rendered = can.isFunction(this.options[name]) ?
- this.options[name].call(this, param) :
- can.view(this.options[name], param);
+ var op = this.options[name],
+ rendered = can.isFunction(op) ? op.call(this, param) : can.EJS({ text : op })(param);
return this._wrapWithTag(rendered, param);
},
View
@@ -134,26 +134,4 @@ steal('jquery', 'funcunit', 'canui/list', 'can/view/ejs', function($) {
var el = container.list('rowElements', people[0]);
equal(can.$.trim(el.html()), 'John I', 'Got element with correct HTML');
});
-
- test("view content", function() {
- can.view.ejs('list_test', '<%= this.name %>');
- var people = new can.Observe.List([
- {
- name : 'Rendered I',
- age : 10
- }, {
- name : 'Rendered II',
- age : 18
- }
- ]);
-
- var container = $('<ul>').appendTo('#qunit-test-area').list({
- view : can.view('list_test'),
- tag : 'li',
- list : people
- });
-
- equal(container.find('li').length, 2, 'Two items rendered');
- equal($.trim(container.find('li:first').html()), 'Rendered I', 'First li rendered');
- });
})

0 comments on commit 2825dd6

Please sign in to comment.