event-handling

How to run a function once when binding to multiple events that all trigger in Javascript?

雨燕双飞 提交于 2019-12-01 06:32:27
问题 I have a search input that listens to keyup and change to trigger an update of a listview via Ajax. Looks like this: input.on('keyup change', function(e) { if (timer) { window.clearTimeout(timer); } timer = window.setTimeout( function() { timer = null; val = input.val(); el = input.closest('ul'); // run a function - triggers Ajax widget[func](dyn, el, lib_template, locale, val, "update"); }, interval ); }); All working nice, except the handling of the timeout and binding, which causes double

How can I retrieve the previous value of a DataGridView cell using the CellValueChanged event?

怎甘沉沦 提交于 2019-12-01 06:10:29
I am writing a C# application that uses a DataGridView and I would like to validate the input each time a user changes the data that's there. I began by using the CellValidating event which has a really nice CancelEdit() method that will return the cell to its previous value. However, this event is fired every time the user leaves the cell, regardless of whether or not it has changed. Does CellValueChanged support a sort of cancel or rollback method to the previous value? This way I would be able to still validate the data, but not waste time with cells that didn't need it, but would prefer

How do I prevent any button click events from queuing until the event handle is finished with the first call

ぃ、小莉子 提交于 2019-12-01 06:04:51
I want to prevent a button click from queuing. In testing I have a Form, a Button and in the Code-Behind I have the event handler: private void button1_Click(object sender, EventArgs e) { if (_codeRunning) return; _codeRunning = true; //Application.DoEvents(); //button1.Enabled = false; _click ++; Debug.WriteLine("Click Number: " + _click); Task.Delay(5000).Wait(); //button1.Enabled = true; _codeRunning = false; } When I run debug and click the button twice or three or four times rapidly, Debug Output shows each click about five seconds after the last one. What I would like it to show is a

Exception not handled in Form Load Event

自古美人都是妖i 提交于 2019-12-01 05:40:23
问题 I just came across odd behavior with exception handling in .Net. (I'm using C# in MS Visual Studio 2008, but one question I saw here seemed to imply that what I see is true throughout the .Net world.) I am writing a plain WinForm application. I am intentionally causing an unhandled exception to be thrown inside a form_load event handler, outside of any try block. I get no notification. If an unhandled exception occurs in a normal method, a message pops up telling me that the exception

Syntax to send two strings in eventArgs

[亡魂溺海] 提交于 2019-12-01 05:28:25
In the following code I need to know the syntax of passing two strings when the event is raised. [PublishEvent("Click")] public event EventHandler<EventArgs<string>> MyEvent; Thanks, Saxon. The cleanest way is to create your own class that derives from EventArgs : public class MyEventArgs : EventArgs { private readonly string _myFirstString; private readonly string _mySecondString; public MyEventArgs(string myFirstString, string mySecondString) { _myFirstString = myFirstString; _mySecondString = mySecondString; } public string MyFirstString { get { return _myFirstString; } } public string

Am I using the right approach to monitor the tasks I want to perform when a handle is created?

眉间皱痕 提交于 2019-12-01 05:23:24
Is there a generally-accepted best practice for creating an event handler that unsubscribes itself? E.g., the first thing I came up with is something like: // Foo.cs // ... Bar bar = new Bar(/* add'l req'd state */); EventHandler handler = new EventHandler(bar.HandlerMethod); bar.HandlerToUnsubscribe = handler; eventSource.EventName += handler; // ... // Bar.cs class Bar { /* add'l req'd state */ // .ctor public EventHandler HandlerToUnsubscribe { get; set; } public void HandlerMethod(object sender, EventArgs args) { // Do what must be done w/ add'l req'd state ((EventSourceType)sender)

Sencha Touch 2 - prevent a-href events (a-href event handling)

我只是一个虾纸丫 提交于 2019-12-01 05:17:48
in my Sencha Touch 2 application I need to handle redirection events on my own. By this I mean I need to be able to handle a href events and do the redirection myself. I'm using the following code: Ext.Viewport.element.addListener("tap", function(e) { e.stopEvent(); e.stopPropagation(); e.preventDefault(); var href = e.target.getAttribute("href"); // ... my code ... }, this, {delegate: "a"}); By none of the above mentioned functions work (stopEvent, stopPropagatioon, preventDefault). The application always opens the link in my app web view. Is here any possible way to disable a href opening

Best way to intercept a Button postback

蓝咒 提交于 2019-12-01 05:11:55
I've seen other solutions like this one which is pretty straightforward but what if the javascript function does more than just confirm('sure?'); ? I never know when it will return a bool. So I've decided to implement all my ASP.NET Buttons like this: <button id="btnDelete" name="btnDelete" class="btn">Delete</button> <asp:Button ID="_btnDelete" runat="server" OnClick="_btnDelete_Click" style="display:none;" /> $('#btnDelete').click(function (e) { $.blockUI({ message: $('#divConfirmDeleteModal'), overlayCSS: { cursor: 'default' }, css: { cursor: 'default' }, baseZ: 5555 }); return false; }); $

Vuejs - bubbling custom events

十年热恋 提交于 2019-12-01 04:51:42
Is there a way to allow events to bubble up when using a component within a component? My application is a dynamic menu. The dynamic menu is a component ( dyn-menu ) and it uses a local component ( menu-item ) for each of the <li> elements. Each <menu-item> has a click handler associated with it that emits a custom event (with an ID for menu item in the full implementation). But the application doesn't see the events issued by <menu-item> because they are not bubbled up. Is there a way to allow the <menu-item> component, which is local to the <dyn-menu> component, emit the event and still

How to make live custom events in jQuery

自古美人都是妖i 提交于 2019-12-01 04:47:55
jQuery has a really handy event binder called live() which will add events to DOM elements on the fly (even for the elements that will be added later to the DOM). The problem is that it's only working on specific events ( listed here in documentation ). I really want to have live events for focus,blur and change which is not supported by live right now. Besides, if I can make live custom events, it will be big game changer for my app. Most of the code that I have right now is dedicated to rebinding old events (change, focus, and custom events for making items draggable or resizable) to new dom