event-handling

How to debug JavaScript / jQuery event bindings with Firebug or similar tools?

喜你入骨 提交于 2019-11-27 23:53:18
问题 I need to debug a web application that uses jQuery to do some fairly complex and messy DOM manipulation. At one point, some of the events that were bound to particular elements, are not fired and simply stop working. If I had a capability to edit the application source, I would drill down and add a bunch of Firebug console.log() statements and comment/uncomment pieces of code to try to pinpoint the problem. But let's assume I cannot edit the application code and need to work entirely in

How to prevent other event handlers, from first handler, in jQuery

喜欢而已 提交于 2019-11-27 23:26:28
If you attach two or more event handlers to an HTML element, they would be executed one after the other. However, if you want to stop the subsequent event handlers, based on a condition checked in the first handler, then what you should do? For example: <div id='target'> </div> <p id='result'> </p> I'd like to cancel the second handler, if the first handler is cancelled. $(function() { var target = $('#target'), result = $('#result'); target.click(function(e) { result.append('first handler<br />'); // Here I want to cancel all subsequent event handlers }); target.click(function(e) { result

How to register multiple external listeners to the same selection in d3?

三世轮回 提交于 2019-11-27 22:58:59
I'm writing a project in d3 in which I have an html page incorporating two external javascript files, say script_1.js and script_2.js . I need to register one event listener from script_1.js and another from script_2.js for the change event on a select element. At present I have this line in my html: <select id="timebasis" class="selector" onchange="selectIndexSp(this),selectIndexBt(this)"> where selectIndexSp(object) and selectIndexBt(object) are defined respectively in script_1.js and script_2.js. I don't like this approach at all, and I'd like to know how to perform the same task in d3

Getting Matlab handles events or properties

时光怂恿深爱的人放手 提交于 2019-11-27 22:29:49
问题 The question How may I get the list of events and properties for a handle of double type, as a figure , axes ? The issue Matlab documentation says to you to use the WindowButtonDownFcn , WindowButtonMotionFcn , and so on in order to listen to whatever happens at your interface. The issue is that this properties are very limited as the following fact: Keeping Variables in Scope When MATLAB evaluates function handles, the same variables are in scope as when the function handle was created. (In

EventHandler with custom arguments

♀尐吖头ヾ 提交于 2019-11-27 22:20:51
I've been looking for an answer for about an hour on Google but I did not found exactly what I'm looking for. Basically, I have a static Helper class that helps perform many things I do frequently in my App. In this case, I have a method named "CreateDataContextMenu" that creates a context menu on a given TreeView control. public static void CreateDataContextMenu(Form parent, TreeView owner, string dataType) { ... } TreeView owner is the control in which I will associate my context menu. Then later on I add a Click event to a MenuItem like this: menuItemFolder.Click += new System.EventHandler

Execute code when a WPF closes

早过忘川 提交于 2019-11-27 21:16:42
I am not familiar with using event handlers, and I was wondering if anyone had or could direct me to some code that shows how to use an event handler that will execute code on the Close/Closed event? I know this can be done because of this answered question: Run code on WPF form close But I need some direction. Thank you =) It's just this XAML <Window ... Closing="Window_Closing" Closed="Window_Closed"> ... </Window> and code for both the Closing and Closed events private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { ... } private void Window_Closed(object

How to use a function that takes arguments with jQuery's change() method?

强颜欢笑 提交于 2019-11-27 20:23:21
I'm using jQuery version 1.5. I am looking at jQuery's change() function and specifically at this bit: .change( [ eventData ], handler(eventObject) ) eventData: A map of data that will be passed to the event handler. handler(eventObject): A function to execute each time the event is triggered. What exactly is a "map of data" in JavaScript? How can I use the following test function as an event handler? var myHandler = function(msg){alert(msg);}; I've tried this: $("select#test").change(["ok"], myHandler); and the alert reports [object Object] See event.data . The data is not passed as argument

Attach event handler to button in twitter bootstrap popover

家住魔仙堡 提交于 2019-11-27 20:08:24
问题 I am using the twitter bootstrap popovers, In the popover I am adding a button, I need to attach a click handler to the button, but the way popover works is each time it shows it removes and re-creates the element, instead of just showing/hiding it, hence removing any event handlers I have associated with said button. I am creating several popovers all with their own version of the button, so just applying a class to the popover won't work (unless I generate a different class for each one :/)

How to remove all Click event handlers? [duplicate]

本秂侑毒 提交于 2019-11-27 18:38:03
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How would that be possible to remove all event handlers of the Click event of a Button? I want to remove all click event handlers from a button. I found this method in Stack Overflow question How to remove all event handlers from a control . private void RemoveClickEvent(Button b) { FieldInfo f1 = typeof(Control).GetField("EventClick", BindingFlags.Static | BindingFlags.NonPublic); object obj = f1.GetValue(b);

Should I instantiate a new delegate or not?

安稳与你 提交于 2019-11-27 18:33:49
问题 I just realized I can add an event handler in two ways: Consider an event handler like so: private void MyEventHandler() {} Method 1: Instantiate a new delegate MyObject.MyEvent += new Action(MyEventHandler); Method 2: Add event handler without instantiating a new delegate MyObject.MyEvent += MyEventHandler; Is there any difference in between these two implementations that should be considered? 回答1: There is no difference, the generated IL is the same. The shorter form was introduced in .net