event-handling

Which JS event is fired when Chrome gets the download file?

倾然丶 夕夏残阳落幕 提交于 2019-11-30 00:24:17
I am having a problem with onLoad event of an iframe on Google Chrome. I created an iframe and set value for its "src" attribute to get a file from server. While server is processing, a waiting box is displayed until client gets the returned file. I tried to use the onLoad event of iframe to detect when client get the file to turn off that waiting box, but on Google Chrome that event handler does not work. With Firefox, when client gets a file, a "Save to" popup will be displayed automatically and event "load" will be fired, but this is not happen on Chrome. Could you please tell me how to

Binding an existing JavaScript function in jQuery

爱⌒轻易说出口 提交于 2019-11-30 00:11:36
Using jQuery I want to bind an existing function to a button. I've been through the documentation and have found the bind method but the examples on the jQuery bind newly created functions where as I want to bind a function that's already hard coded, e.g: function fHardCodedFunction(){ //Do stuff } function fBindFunctionToElement(){ $("#MyButton").bind("click", fHardCodedFunction()); } Is this possible? Or am I going about this the wrong way? The plain fHardCodedFunction already refers to the function and the suffix () will just call it. So just pass the function instead of calling it and

MATLAB event and infinite sleeping or checking loop

百般思念 提交于 2019-11-29 23:32:46
问题 I need to perform data analysis on files in a directory as they come in. I'd like to know, if it is better, to implement an event listener on the directory, and start the analysis process when activated. Then having the program go into sleep forever: while(true), sleep(1e10), end or to have a loop polling for changes and reacting. I personally prefer the listeners way, as one is able to start the analysis twice on two new files coming in NEARLY the same time but resulting in two events. While

Accessing class member variables inside an event handler in Javascript

点点圈 提交于 2019-11-29 23:06:09
I have a quick question regarding the proper way to access Javascript class member variables from inside of an event handler that class uses. For example: function Map() { this.x = 0; this.y = 0; $("body").mousemove( function(event) { this.x = event.pageX; // Is not able to access Map's member variable "x" this.y = event.pageY; // Is not able to access Map's member variable "y" }); } Rather than changing the member variable of the "Map" class, the "this.x" in the event handler tries to affect the "x" member variable of the element that triggered the event. What is the proper way to access the

C# event handling (compared to Java)

不想你离开。 提交于 2019-11-29 21:58:15
I am currently having a hardtime understanding and implementing events in C# using delagates. I am used to the Java way of doing things: Define an interface for a listener type which would contain a number of method definitions Define adapter class for that interface to make things easier if I'm not interested in all the events defined in a listener Define Add, Remove and Get[] methods in the class which raises the events Define protected fire methods to do the dirty work of looping through the list of added listeners and calling the correct method This I understand (and like!) - I know I

Passing arguments to an event handler

南楼画角 提交于 2019-11-29 21:27:08
In the below code, I am defining an event handler and would like to access the age and name variable from that without declaring the name and age globally. Is there a way I can say e.age and e.name ? void Test(string name, string age) { Process myProcess = new Process(); myProcess.Exited += new EventHandler(myProcess_Exited); } private void myProcess_Exited(object sender, System.EventArgs e) { // I want to access username and age here. //////////////// eventHandled = true; Console.WriteLine("Process exited"); } Yes, you could define the event handler as a lambda expression: void Test(string

button onclick function firing twice

心不动则不痛 提交于 2019-11-29 20:52:53
I have a button that calls a javascript function using an event handler. For some reason, the event handler is being called twice. Here is my button (I am using a php object to generate the code, that's why there are a lot of empty tags): <button name="addToCart" value="" size="" onclick="" src="" class="addToCartButton" id="0011110421111" type="button" formtarget="_self" formmethod="post" formaction="" data-mini="true" width="" height="" placeholder="" data-mini="1" onkeypress="" >Add To Cart</button> Here is my event handler: $('.addToCartButton').click(function() { alert("bob"); //addToCart

EventBus/PubSub vs (reactive extensions) RX with respect to code clarity in a single threaded application

此生再无相见时 提交于 2019-11-29 19:52:13
Currently, I am using an EventBus/ PubSub architecture/pattern with Scala (and JavaFX) to implement a simple note organizing app (sort of like an Evernote client with some added mind mapping functionality) and I have to say that I really like EventBus over the observer pattern. Here are some EventBus libraries : https://code.google.com/p/guava-libraries/wiki/EventBusExplained http://eventbus.org (currently seems to be down) this is the one I am using in my implementation. http://greenrobot.github.io/EventBus/ Here is a comparison of EventBus libraries : http://codeblock.engio.net/37/ EventBus

Get select element value on event using pure JavaScript

那年仲夏 提交于 2019-11-29 17:57:12
问题 I want to get the value of a select element when the select element is clicked! I want to do it without an onchange attribute in the HTML. I would like to achieve this without jQuery. I don't want to include a jQuery framework into this website when this tiny script is the only thing I need. var select_element = document.getElementById('product-form-user-enquiry-type'); select_element.onchange = function(e){ if (!e) var e = window.event; var svalue = select_element.value; alert( svalue ); }

Passing events to parent

南楼画角 提交于 2019-11-29 17:56:44
问题 I'd like to create an app where some events are supposed to be handled as if they were delivered to parent containers. For example I've got a JPanel which contains JLabel . The top JPanel implements mousepress and dragging right now. What do I need to do, in order to make the events look like they arrived to JPanel instead of the label itself. (changing source object is important) Is there some better solution than actually implementing the events and replicating them in the parent? (this