event-handling

jQuery unload event only for close window not for Link navigation

半腔热情 提交于 2019-12-01 01:42:46
I am using this code for logging out user when closes the page, but the user will logout also when clicking on other links (same website): $( window ).unload(function() { $.ajax({url:"?logout&leave=yes", async:false}) }); Is there any way to distinguish between link navigation and real page close? EDIT: I am currently implemented this solution, but it lacks to detect page reload $('a').click(function(){ var url = $(this).attr("href"); window.onbeforeunload = null; $(window).unbind('beforeunload'); window.location = url; }); Try the following solutions, hope this helps <script> $(window).bind(

Vuejs - bubbling custom events

∥☆過路亽.° 提交于 2019-12-01 01:31:17
问题 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

Meaning of Event in php

你。 提交于 2019-12-01 01:29:45
I know php and nodejs too,in javascript we have asynchronize programming ,so I understand meaning of event in it.but I saw Event in Yii and Zend 2 and use them too,but I can't understand the meaning of it,how it works in php and what exactly does in it? First of all, there are no events in PHP An event is an abstraction for callback functions with their name. Typically, we'd define them as $eventName => $listener , where $listener is a callback function for the $eventName What is the difference between events and regular callback functions? Again - the core point to remember, is that events

Catch change event on input field dynamically added to Jquery Datatables table

爷,独闯天下 提交于 2019-12-01 01:28:18
问题 I have an ajax call that uses the following code to add some rows to a data table for each record in the response: strAppName = data.Application_Name maintCost = '<input class="maintCostField" appid="' + data.Application_ID + '" type="text" placeholder="$">'; $('#myReport').dataTable().fnAddData([ strAppName, maintCost, etc, etc ]); I've tried the following selectors/events to catch changes to the text box, but none of them trigger. They are in the document.ready section... $(".maintCostField

Event loop implementation for Python 3?

你说的曾经没有我的故事 提交于 2019-12-01 00:41:52
Does anyone know of an event loop library (or bindings) available for Python 3? It's okay if it only does UNIX systems, though I would prefer something that does Windows as well. ETA : I realize that it is not terribly difficult to write an event loop system. However, I don't want to reinvent the wheel (we are still encouraging not doing so these days, right? ;-)) This is planned for a server application, so obviously I'd want something that isn't tied to a GUI widget toolkit or something. If the answer is "Nope, there isn't one" (probably; I sure as heck can't find one) then I will most

Are JQuery events usables with Dom addEventListener?

自古美人都是妖i 提交于 2019-12-01 00:17:53
I'm using Bootstrap4 alpha in my project, and for some investigations purposes, i'm trying to catch a JQuery event using DOM addEventListener() . The event is fired using the JQuery $("#mypanel").trigger("shown.bs.collapse") function by bootstrap in it's collapse component. If i try to catch it using the JQuery $("#mypanel").on("shown.bs.collapse", ... ) function, everything works just fine. But if i use $("#mypanel").get(0).addEventListener("shown.bs.collapse", ... ) on the corresponding DOM elements, the event is not "catched" Are JQuery event system and standard DOM event system are NOT

Event handler that will be called when an item is added in a listbox

主宰稳场 提交于 2019-11-30 22:49:24
问题 Is there an event handler that will be called when an item is added in a listbox in WPF? Thanks! 回答1: The problem is that the INotifyCollectionChanged interface which contains the event handler is explicitly implemented, which means you have to first cast the ItemCollection before the event handler can be used: public MyWindow() { InitializeComponent(); ((INotifyCollectionChanged)mListBox.Items).CollectionChanged += mListBox_CollectionChanged; } private void mListBox_CollectionChanged(object

mouseover circle HTML5 canvas

旧城冷巷雨未停 提交于 2019-11-30 22:19:43
I am wondering how to set an area as a semi-complex shape (circle) defined in the canvas so when the user mouse overs the shape, a function will be called. I do not wish to use libraries at all such as KineticJS etc. Currently I have added an event listener to the canvas element so that on mouse move I call multiple functions; one of which works out the mouse x/y coordinates relative to the canvas. As such, any rectangular shape is easy to 'listen' for using a basic if statement (as the canvas is interactive and redrawn each mouse move). For circular objects, as well as say triangular objects,

Prevent refreshing / reloading a page with JavaScript

你。 提交于 2019-11-30 22:00:05
I know this is not recommended, but I need it because I have an iframe inside the page who has the actual content and I want that when the users hits refresh button, iframe reloads not entire page. I know I have to call onunload / onbeforeunload event, but I don't want to ask me if I want to leave the window, just don't. Is that possible? I've got handled the F5 key, but I like to prevent refreshing from button too. UPDATE: I wrote this 5 years ago, browsers do different stuff now, you can still use this for testing your browser set, but your experience may vary from my old research.

Is there any way to detect if user pressed “Stay on page” or “Leave page” in beforeunload event?

牧云@^-^@ 提交于 2019-11-30 21:39:09
Is there any way that I could detect in the following code that either user clicked "leave page" or "stay on page" button ? $(window).on('beforeunload', function (){ return "You save some unsaved data, Do you want to leave?"; }); With a few hacks you can at least determine if the user stayed. If the user left the page, there's not much you can do about that : var timeout; $(window).on('beforeunload', function (){ timeout = setTimeout(function() { // user stayed, do stuff here }, 1000); return "You save some unsaved data, Do you want to leave?"; }); FIDDLE iirc, the unload event is not