javascript - BackboneJS 'click' event not firing when 'focusout' event exists -
i have view in trigger dropdown provides number of options when text input in focus (similar idea select2) in backbonejs:
events: { 'click .option': 'clickitem', 'focusin .big-select-input': 'focusin', 'focusout big-select-input': 'focusout' }, focusin: function() { this.$el.find('.big-select-options').show(); }, focusout: function() { this.$el.find('.big-select-options').hide(); }, clickitem: function() { console.log('item clicked'); } <input type="text" class="big-select-input" /> <div class="big-select-options" style="display:none;"> <div class="option">item</option> <div class="option">item</option> <div class="option">item</option> <div class="option">item</option> </div>
what have noticed, click event option doesn't fire when 'focusout' event exist. if remove focusout event (or blur event), click works.
how can click , focusout both work @ same time?
here barebones example http://jsbin.com/bivilujili/1/edit?html,js,console,output
if understand correctly, think you're clicking option you're not. when try click option input has lose focus. when input loses focus you're hiding option's container. can't click anymore. hide.
you need update logic not hide them.
Comments
Post a Comment