Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed onChange issue with menu

  • Loading branch information...
commit cb5a4f1d4633ece14fbf2638ed5f8c00c71e20fc 1 parent 6295aea
@jamesstrate jamesstrate authored
Showing with 11 additions and 15 deletions.
  1. +9 −4 src/js/menu.js
  2. +2 −11 test/pulldown.js
View
13 src/js/menu.js
@@ -98,19 +98,24 @@
$.el.span(this._labelForItem(item) || '\u00a0').appendTo(anchor);
var clickFunction = _.bind(function(e, silent) {
- if(!!this._selectedAnchor) $(this._selectedAnchor).removeClass('selected');
- this._setSelectedItem(_(item).isEqual(this.options.emptyItem) ? null : item, silent);
+ if(!!this._selectedAnchor) $(this._selectedAnchor).removeClass('selected');
this._selectedAnchor = anchor;
$(anchor).addClass('selected');
- if(_(this.options.onChange).isFunction()) this.options.onChange(item);
+ //check if item selected actually changed
+ var changed = this._determineSelectedItem() !== item;
+
+ if(_(this.options.onChange).isFunction() && changed) this.options.onChange(item);
+
+ this._setSelectedItem(_(item).isEqual(this.options.emptyItem) ? null : item, silent);
+
return false;
}, this);
$(anchor).click(clickFunction);
- if(this.select) clickFunction(null, true);
+ if(select) clickFunction(null, true);
menu.appendChild(liElement);
},
View
13 test/pulldown.js
@@ -84,20 +84,11 @@ $(document).ready(function() {
test("placeholder", function(){
- var coffee = new Backbone.Model({
- roaster: 'Counter Culture',
- name: 'Baroida',
- roastedOn: new Date(2012, 2, 28, 6, 30),
- acidic: true,
- region: regions.at(0)
- });
-
var pulldown = new Backbone.UI.Pulldown({
- model : coffee,
- content: 'region',
+ content: 'test',
alternatives: regions,
altLabelContent: 'name',
- placeholder: "Select a region..."
+ placeholder: 'Select a region...'
}).render();
//check the label on pulldown
Please sign in to comment.
Something went wrong with that request. Please try again.