Common Event Listener for multiple instances of custom element - event-listener

I am creating a dropdown-multi-select custom element.
When user clicks outside the dropdown, I would like to close the dropdown, therefore I am attaching an event listener to the window to detect outside-click.
My Problem is when multiple instance of this component is created, there will be multiple event listeners doing the same job.
I intend to put this component in every row of a table with 1000 rows
I would like to know
Is there a better way to do it.
Having 1000s of event listener, should I be concerned about it

Even if you have 1000s of drop-down custom element, only one is active at a given time.
Therefore you should attach on window the event listener for the active (and expended) drop-down list...
...and detach it when the drop-down list has collapsed.

Related

Access 2016 Prevent "change" event from firing

I have a combo box in an Access form with 2 values Yes / No. The user opens the form and enters the reference number and pushes a button to run a macro. The macro executes a query to return data based on the reference number. The results of query are displayed in various text boxes.
After the combo box is built, the macro selects the appropriate value based on the query. The problem I'm having is that the "change" event is triggered because the combo box is loaded for the first time. I want to prevent this.
After reviewing the data, the user can choose to change the value in the combo box. At this time, I want the change event to fire because the additional macros are run that update multiple tables in the database.
Can I prevent the "change" event from firing when the form is loaded with data but allow it to fire when the combo box is changed?
Thanks in advance for any help or suggestions you provide........

Can I add 2 different button classes' in a trigger under the main tag and get proper data in my GA?

In a pricing page, there is a "Buy" button when user clicks on the button, it takes to a page where the user chooses payment type and again there is a button with another class, I want to track both of them. Is it possible to set up 2 button classes(in one trigger) under the button click tag and get proper data in GA?
You can achieve this, but not in this way, as visible on your screenshot. These conditions have AND relation. So your current trigger requires a click on an element with a class containing payment-button price-btn AND btn-pay at the same time.
So you need to create two separate triggers for the two class variants, and attach both of them to the same tag as firing triggers, as those will have OR condition among themselves.
Please note, that payment-button price-btn will look for this string. So if there's any chance, that the classes don't appear in this exact order, you might want to go for just one of them, or separate these two classes in two rows of one trigger, payment-button and price-btn.

Auto complete a dropdown menu in a cq5 dialog based on input from a previous dialog field

My custom CQ5 component has a dialog which consists of 2 drop down menus. I would like to automatically set a default value to second menu depending on whatever is the value selected from the previous drop down.
How can I achieve this?
you can register handlers for different events triggered by the widgets. You can use the "selectionchanged" event to register a function that will read the new content from the dropdown and then use the setValue() method in the second dropdown to put whatever you want there.
To obtain the second dropdown from the first you can use the nextSibling() method.
The widget documentation will help you a lot. look for "selection"

Lose events for extjs form

I have a big form on extjs which opens in window, and, for speed reasons, i cache it in hidden panel. There is can be only one window at time, so the cached form is single too. On show event i add form to window, with no rendering and with suspendLayout option for form. On close event i move the form to hidden panel, with panels add method. I do not use remove method not for window not for panel. So, for several times all perfect, but after 3- 5 window openings form lose all of its events: buttons, comboboxes, triggers and other controls are not responding. Where is the problem? Thank you.
It is difficult to know for certain but my theory is that the observable object that your listeners are setup on is garbage collected at some indeterminate time period of inactivity.
I have seen this occur on an object representing the body of an iframe that is watched from the parent window. Click events from the body will work for some time and then all events will stop.
One way to test the theory is to store object reference in a global variable - this is NOT what you want to do in any app but worth a try just to test. Global vars are never garbage collected.

Listener function for gwt widgets

For my project when a button is clicked, the click event should then wait and listen to the next two clicks on different widgets and then connect them so as to form relationship between them.
Right now i an trying to use FocusListener without success. Any suggestion will be of great help.
Thank you.
I would think you'd just want an ClickListener for each object. Handle "enabling" the other two objects in the first object's click event, then when those two objects are clicked on, invoke the method to form the relationship. You don't want to wait in the first object's event handler.