event-handling

Trigger a click event on an inner element

孤街浪徒 提交于 2019-12-03 01:45:49
A row in a table where each first cell contains a link needs to be clicked and open a url. <table> <tr> <td><a class="fancybox" href="detail.aspx?CID=67525">LT5C260A436C41</a></td> <td>more data</td> </tr> <tr> <td><a class="fancybox" href="detail.aspx?CID=17522">LA5C260D436C41</a></td> <td>more data</td> </tr> ... </table> The complete row should be clickable instead of only the link top open the detail page in a fancybox , ie in the page itself. So I tried to do something like this: $("table tr").bind('click',function(e) { e.stopPropagation(); $(this).find("a").trigger('click'); }); But it

How to remove event listener in Chrome extension

拟墨画扇 提交于 2019-12-03 01:34:52
I am trying to remove the onRequest listener added by chrome.extension.onRequest.addListener after a request is made, like this: chrome.extension.onRequest.addListener( function(request){ chrome.extension.onRequest.removeListener(); other_function(request); } ); The problem is that I don't know if this works or not. I tried chrome.extension.onRequest.hasListener , which seems not to give the right answer, so I am wondering if there are some other ways to remove the onRequest listener or check if the listener exists or not. Thanks! removeListener takes an argument. You need to name the listener

Is it bad practice to write inline event handlers

柔情痞子 提交于 2019-12-03 00:53:37
Is it bad practice to write inline event handlers ? For me, I prefer use it when I want to use a local variable in the event handler like the following: I prefer this: // This is just a sample private void Foo() { Timer timer = new Timer() { Interval = 1000 }; int counter = 0; // counter has just this mission timer.Tick += (s, e) => myTextBox.Text = (counter++).ToString(); timer.Start(); } Instead of this: int counter = 0; // No need for this out of Boo & the event handler private void Boo() { Timer timer = new Timer() { Interval = 1000 }; timer.Tick += timer_Tick; timer.Start(); } void timer

Funky jQuery mouseleave behavior

空扰寡人 提交于 2019-12-03 00:35:23
I have a menu-like drop down container that hides via binding the "mouseleave" event. <div id="container"> <select> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </div> The problem I am having is when my container's child elements contain a SELECT object where the OPTIONS of the SELECT physically extend outside the bounds of the container. Consequently, hovering over the OPTIONS outside of the bounds trigger the "mouseleave" event to fire and close my drop down. The SELECT is a child of the container, so in this case I would expect the

Difference between event handlers and callbacks

女生的网名这么多〃 提交于 2019-12-03 00:14:02
问题 What is the difference between an event handler and a callback function? 回答1: Generally speaking, a 'callback' is under the control of the detecting process. So you tell a GUI manager "call myaction when this button is pressed" and the GUI manager calls the action when the button is pressed. Event Handlers on the other hand operate at one step removed. The GUI manager is configured to send messages to an event handler. You tell an event manager that button pushes are handled by the myaction

How to make a click or double click on a word on a web page to trigger an event handler?

余生颓废 提交于 2019-12-02 22:19:49
For a page like http://www.answers.com if the user double clicks on any word in the page, a pop up box will show up and shows the definition for that word. I can think of a way to use DOM scripting to break up all words in the page and then make each of them go under a separate "span" element... but otherwise isn't it true that if all the text is under a "p" element, then the "p" element node get triggered to handle the double click event, but there is no easy way of telling which word is clicked on? You simply add a double click event to the entire document, like so: function get_selection()

How to disable JQuery keypress event for just one element?

末鹿安然 提交于 2019-12-02 22:03:15
On my site I have registered a keypress event handler for the whole document. $(document).keypress(myhandler); And I handle the 'space' key to scroll a list. Trouble is, there is an <input type='text' /> element, and I don't want 'space' keypress to scroll the list when it is entered in the input. I couldn't find any information in the "event" object passed by JQuery to the handler, to identify where the source of the event is. Tom Bartel Alternatively, you could attach another event handler to the input field, and in this handler stop the propagation of the event: jQuery('#input-field-id')

the getSource() and getActionCommand()

六眼飞鱼酱① 提交于 2019-12-02 20:38:30
What is getSource? and what does it return? and what is getActionCommand() and what does it return?? I am getting confused between these two can anyone give or differentiate them to me? what's the use of getSource and getActionCommand() in UI's? specifically TextField or JTextField? Assuming you are talking about the ActionEvent class, then there is a big difference between the two methods. getActionCommand() gives you a String representing the action command. The value is component specific; for a JButton you have the option to set the value with setActionCommand(String command) but for a

UIActivityViewControllerCompletionHandler How to?

隐身守侯 提交于 2019-12-02 20:24:19
I am trying to use the UIActivityViewControllerCompletionHandler , but i dont quite get how.. I want to detect when the user finishes or dismisses this view controller ( UIActivityViewController ). Anyone knows how? typedef void (^UIActivityViewControllerCompletionHandler) (NSString *activityType, BOOL completed); The second parameter of the completion handler tells you whether the user dismissed the controller. If they dismissed the controller, completed will be set to NO . There's more details in the completion handler's documentation . Here's how you show a sharing dialog and set its

Which methods can be used to make thread wait for an event and then continue its execution?

无人久伴 提交于 2019-12-02 19:17:46
I have a thread running that delegates out some tasks. When a single task is complete, an event is raised saying that it has completed. These tasks need to be run in a specific order and need to wait for the previous task to finish. How can I make the thread wait until it receives the "task completed" event? (Aside from the obvious eventhandler that sets a flag and then a while loop polling the flag) I often use the AutoResetEvent wait handle when I need to wait for an asynchronous task to finish: public void PerformAsyncTasks() { SomeClass someObj = new SomeClass() AutoResetEvent waitHandle =