PDA

View Full Version : Collapse all ComboBox components when Ext.History's change event fires?



paulcrowder
9 Mar 2011, 7:24 AM
I've got a single page application that uses Ext.History to show/hide portions of the page as the user navigates with the browser's back and forward buttons. I have a problem that occurs when a user expands an Ext.ComboBox, then clicks the back button. I hide the element that contains the combo box, but the drop-down portion of the combo remains visible. Since mine is a pluggable system, I don't have control over every single Ext.ComboBox instance that's added to the page, so I can't add an event handler for Ext.History's change event to collapse the combo. I've tried looping through the items in Ext.ComponentMgr.all to find all combo boxes so I can call their collapse() method, but no items whose xtype is "combo" are returned. I've also tried dispatching the click event of the document's body element hoping that it would mimic the user clicking outside the drop-down portion of the combo, but that didn't work either. Any suggestions? Ideally I'd be able to use the same technique for hiding other "floating" elements that are normally closed when the user clicks out of them (e.g. an Ext.ToolTip object).

paulcrowder
9 Mar 2011, 1:51 PM
Update: Dispatching the "mousedown" event rather than the "click" event on the document's body element did what I needed. I used code from this page to dispatch the event across different browsers. It seems to work fine in Firefox, Chrome and IE8.

http://jehiah.cz/a/firing-javascript-events-properly