Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/perka/backbone-ui

  • Loading branch information...
commit dc885257c7ba7331e19a18de297c1cffe160ef24 2 parents 444bee0 + 0bf7375
@jcarrig jcarrig authored
Showing with 19 additions and 5 deletions.
  1. +2 −1  src/js/collection_view.js
  2. +17 −4 src/js/radio_group.js
View
3  src/js/collection_view.js
@@ -100,9 +100,10 @@
_updateClassNames : function() {
var children = this.collectionEl.childNodes;
if(children.length > 0) {
- _(children).each(function(child) {
+ _(children).each(function(child, index) {
$(child).removeClass('first');
$(child).removeClass('last');
+ $(child).addClass(index % 2 === 0 ? 'even' : 'odd');
});
$(children[0]).addClass('first');
$(children[children.length - 1]).addClass('last');
View
21 src/js/radio_group.js
@@ -28,7 +28,7 @@
this.selectedItem = this._determineSelectedItem() || this.selectedItem;
- var ul = $.el.ul();
+ this._ul = $.el.ul();
var selectedValue = this._valueForItem(this.selectedItem);
_(this._collectionArray()).each(function(item) {
@@ -48,13 +48,13 @@
// insert label into li then add to ul
$.el.div({className : 'label'}, label).appendTo(li);
- ul.appendChild(li);
+ this._ul.appendChild(li);
$(li).bind('click', _.bind(this._onChange, this, item));
}, this);
- this.el.appendChild(ul);
-
+ this.el.appendChild(this._ul);
+ this._updateClassNames();
return this;
},
@@ -64,6 +64,19 @@
if(_(this.options.onChange).isFunction()) this.options.onChange(item);
return false;
+ },
+
+ _updateClassNames : function() {
+ var children = this._ul.childNodes;
+ if(children.length > 0) {
+ _(children).each(function(child, index) {
+ $(child).removeClass('first');
+ $(child).removeClass('last');
+ $(child).addClass(index % 2 === 0 ? 'even' : 'odd');
+ });
+ $(children[0]).addClass('first');
+ $(children[children.length - 1]).addClass('last');
+ }
}
});
}());
Please sign in to comment.
Something went wrong with that request. Please try again.