javascript - Backbone.js : select option change event trigger click event also -


i have backbone view selectbox 2 events, change , click.

  • change - additional functionality on selection.
  • click - clear current selection.

but when change option, click event getting triggered.

backbone.view.extend({  events: {     'change #sort-list': 'facetaction',     'click #sort-list': 'clearselection' }, facetaction : function(){ }, clearselection: function(){  //change event getting executed. } 

you need make click #sort-list more specific. if use mouse change selection of #sort-list call click.

if you're trying reset mention on click, create button side of or that. then, handle click #reset-button.

<div class="input-group">   <span class="input-group-btn">     <button class="btn btn-default" type="button" id="reset-button">reset</button>   </span>   <select class="form-control" id="sort-list"></select> </div><!-- /input-group -->  var myview = backbone.view.extend({     events: {         'change #sort-list': this.onchangeselecteditem,         'click #reset-button': this.onclickresetbutton     } }); 

unless missing something, that's need do...


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -