event-handling

Change() inside each() jQuery

╄→尐↘猪︶ㄣ 提交于 2019-11-28 01:54:03
问题 What is the best way to manage this kind of situation : $('.element').each(function() { $sibling = // find a sibling to $this. $mainElement = $(this); // memorize $(this) $sibling.change(function() { // when sibling changes // do something using $mainElement // problem is, $mainElement is not the element you think // $mainElement is the last .element found.... }) }); One solution would be a table... But then there is no advantage for the change() to be nested in the each()... My html example

iOS - UIEventTypeRemoteControl events not received

≡放荡痞女 提交于 2019-11-28 01:45:45
问题 I have this in the AppDelegate (didFinishLaunching): [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; I tried handling the events in the relevant view controllers but that was spotty (some view controllers would get the events and others wouldn't, even when they were first responders). I tried subclassing UIApplication. That didn't work. Now I'm trying to subclass UIWindow and do this (see the comments): - (void)sendEvent:(UIEvent *)event { if (event.type ==

Add event handler dynamically having the delegate name in a string

陌路散爱 提交于 2019-11-28 01:44:09
I need to assign an eventHandler to an object, in this way: _Element.AddHandler(UIElement.MouseLeftButtonUpEvent, new RoutedEventHandler(Vars.Digit), true); but, in fact, I only have a string that contains "Digit" or other method name in the Vars object instance. It is possible to achieve this using reflection or other kind of trick? Thanks. Yes, you can find the method with Type.GetMethod , and the event with Type.GetEvent , then add a handler with EventInfo.AddEventHandler . It may be slightly fiddly - and there'll be a lot of places to put error handling - but it shouldn't be too hard. Don

VBA Outlook event moving email

让人想犯罪 __ 提交于 2019-11-28 01:30:53
I search a way to get the event of a moving item/email in outlook. Can we use an Inspector? Or maybe there's an event handler like itemsent or newmail? Thank you More Details : I have 4 or more mail boxes. Each has an number X of folders and subfolders (1 of them is a livelink box with millions of folders). Some are common box, and there are people who drag common mail. I want to catch every time a mail is moved on a folder in livelink box. An event is fired when an item is added to a collection, in a folder. For example, suppose you had a folder called "Stuff" one level below your default

C#: Thread-safe events

丶灬走出姿态 提交于 2019-11-28 01:25:02
问题 Is the implementation below thread-safe? If not what am I missing? Should I have the volatile keywords somewhere? Or a lock somewhere in the OnProcessingCompleted method? If so, where? public abstract class ProcessBase : IProcess { private readonly object completedEventLock = new object(); private event EventHandler<ProcessCompletedEventArgs> ProcessCompleted; event EventHandler<ProcessCompletedEventArgs> IProcess.ProcessCompleted { add { lock (completedEventLock) ProcessCompleted += value; }

Event not working on dynamically created element

懵懂的女人 提交于 2019-11-28 01:19:44
I'm pulling my hair out trying to figure out why the mouseover event won't work with the .on handler with a dynamically created element from ajax. The only thing that seems to work is the code with .live but I understand that it is deprecated. $(".dropdown ul li").live("mouseover", function() { alert('mouseover works'); }); However, when I try using .on, it will not work - no matter what variations I try (document.ready, .mouseover, etc etc) $(".dropdown ul li").on("mouseover", function() { alert('mouseover works'); }); The event handlers are at the bottom of the code, so they are executed

Event fires more and more times

老子叫甜甜 提交于 2019-11-28 01:10:57
I have a silverlight mvvm application that loads main view with 2 user controls loaded into 2 ContentControls, one with listbox showing items and other with edit button. When i click edit button, 2 new user controls load into the ContentControls, one showing data to edit (EditData) and other having Save and Cancel button (EditAction). When i click save button, it raises an event that is defined in seperate GlobalEvents.cs class like: public event EventHandler OnSaveButtonClicked; public void RaiseSaveButtonClicked() { this.OnSaveButtonClicked(this, EventArgs.Empty); } and i subscribe to it in

ExecuteComplete ADODB Connection event not fired with adAsyncExecute parameter

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 00:29:13
I have a problem trying to catch the completion of a stored proc execute asynchronously. Below my code VBA (in a class module named clsAsync): Option Explicit Private WithEvents cnn As ADODB.Connection Private Sub cnn_ExecuteComplete(ByVal RecordsAffected As Long, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pCommand As ADODB.Command, ByVal pRecordset As ADODB.Recordset, ByVal pConnection As ADODB.Connection) MsgBox "Execution completed" End Sub Sub execSPAsync() Set cnn = New ADODB.Connection Set rst = New ADODB.Recordset cnn.ConnectionString = "connection to my

Is it good idea to use “Control.CheckForIllegalCrossThreadCalls = false” [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 00:23:53
This question already has an answer here: Is it safe just to set CheckForIllegalCrossThreadCalls to false to avoid cross threading errors during debugging? 1 answer I have a class that receives data from serialport. i used action<T> delegate to pass data to the form where it is displayed in a textbox. the thing is i could not access the textbox control, becouse it says: Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on . so i set Control.CheckForIllegalCrossThreadCalls = false , and it is working. is it good idea to do that? or there is a

Getting control name for an event

醉酒当歌 提交于 2019-11-28 00:13:36
In my C# Windows Forms form I have some buttons which are dynamically generated. I assigned the following method on the click event. Is it possible to get the name of the button from which the event is triggered? private void btnBrowsDoc_Click(object sender, EventArgs e) { try { if (openFileDialog1.ShowDialog().Equals(DialogResult.OK)) { gbxDocument.Controls["txtDocument" + count].Text = openFileDialog1.FileName; } else { return; } } catch (Exception ex) { //handle the exception } } digEmAll You can use the sender argument. That is the Control (the button in this case) that has raised the