w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Google Maps V3 removing event listener not working
you overwrite chartLayer and listentothis on every loop, so when you click on a polygon it will always affect the last created polygon(or event) inside the loop. You may easily use this inside the click-callback to access the clicked polygon: google.maps.event.addListener(chartLayer, 'click', function() { google.maps.event.clearListeners(this,'mouseout'); }); (Note that the method is called clearListeners, not removeListeners, as mentioned by Seb P's comment)

Categories : Google Maps

How to define an Event Listener if the Event Listener class is in a namespace
You need to ensure that your namespace is actually being loaded. Aka, somewhere in your composer.json file - are you telling composer/laravel where this namespace resides? If not, that's your first step. You usually need to add it to the psr-0 location, like so: "autoload": { "psr-0": { "MyApp": "src/" } } This tells laravel/composer that your code for the namespace "MyApp" is found at src/MyApp (with your Events folder being a logical extension of that).

Categories : PHP

Symfony 2 event listener - on authentication fail / firewall listener
Take a look at the DefaultAuthenticationFailureHandler class. It should be under SymfonyComponentSecurityHttpAuthentication. This is the default listener that Symfony uses when authentication fails. But you can write your own and use it by adding it to your security.yml like this: firewalls: firewall_name: form_login: failure_handler: your.service.id Here's a complete reference to the security.yml configuration: http://symfony.com/doc/current/reference/configuration/security.html

Categories : PHP

Why is the event listener for the invalid event not being called when using event bubbling?
According to the MDN reference, which is usually accurate and which appears to match reality in this case, invalid events do not bubble. They fire only on the input and the form.

Categories : Javascript

Passing event listener in to event listener?
Somewhere you have a for loop like this: for( i = 0; i < btn.length; i++ ) { // do stuff with btn[i] } Change it to: for( i = 0; i < btn.length; i++ ) { addButton( btn[i] ); } function addButton( button ) { // do stuff with button } The body of the addButton() function will be all of the code that was in your for loop with one difference: everywhere you have btn[i] change it to button. By moving this code into a function, you create a "closure" which preserves the value of the button variable as long as needed, unlike the original code where btn[i] becomes invalid after the loop finishes running. Remember that event listeners are called long after the original code that sets them up finishes. If you use a loop index in the event listener, that index value is

Categories : Javascript

Detect event from iframe works with jQuery event listener on parent, but now with pure JS
Here, your event is triggered on body, so you should listen for events on body, not document : document.querySelector("body").addEventListener("myevent:load",function() { console.log("Hello"); },false); Syntax : https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener

Categories : Javascript

How To Add Event Listener To HTML5 Video Poster Image Load Event
Like this: var poster = $( 'video' ).prop( 'poster' ); if ( poster ) { var image = new Image(); image.onload = function () { alert( 'load' ); }; image.src = poster; }

Categories : Javascript

Adding an event listener to a div to perform an event if the div becomes empty (has no children)
jQuery has remove event fired when element is removed $(el).on("remove", function () { alert("Element was removed"); }); You could use live (if they are appended dynamically to parent container) or on (if statically) method to bind this event to child nodes of particular container and on every remove event check if parent container has any child nodes. If not then do some actions.

Categories : Javascript

How to add Event Listener for Event after Youtube video is finished playing
Here's your working code, and then I'll explain it: var params = { allowScriptAccess: "always" }; var atts = { id: "myytplayer" }; var video = swfobject.embedSWF("http://www.youtube.com/v/elvOZm0d4H0?enablejsapi=1&playerapiid=ytplayer&version=3&rel=0&autoplay=1&controls=1", "ytapiplayer", "450", "250", "8", null, null, params, atts); onYouTubePlayerReady = function (playerId) { ytplayer = document.getElementById("myytplayer"); ytplayer.addEventListener("onStateChange", "onPlayerStateChange"); }; onPlayerStateChange = function (state) { if (state === 0) { alert("Stack Overflow rocks!"); } }; The first thing is to note that, when you embed the player SWF with swfobject, you are telling that library to REPLACE the div you reference wit

Categories : Javascript

Android - RemoveUpdates not removing listener
First of all when using LocationManager.NETWORK_PROVIDER you should not see the GPS symbol at all. I see you are using Google Maps Android API v2, so my guess is outside of the code you put here you have map.setMyLocationEnabled(true); which shows blue dot and continuously updates it while showing Activity with MapFragment/MapView.

Categories : Android

JavaScript not removing listener when reading from array
The reason is that creatHandler always returns a new function and not the same one you attached. You should store the handlers and fetch them when you want to remove them. var handlers = []; function createHandler(i) { if (!handlers[i]) { console.log('Created ' + i); handlers[i] = function () { alert(array[i][AGE]); }; } return handlers[i]; } You can see it in action too: http://jsfiddle.net/balintbako/TQxua/

Categories : Javascript

jQuery listener for PHP event
Simplest thing would be to check if #error-box contains any text: $(document).ready(function(){ if ($.trim($("#error-box").text()).length < 1) { $("#error-box").hide(); } }

Categories : PHP

Afterevent event listener
Since it sounds like what you're really trying to do is to get notified anytime a textarea has been changed, here's some code I've used for that specific issue. It will call your callback anytime the content has been changed via keyboard, drag/drop, mouse, etc... (function($) { var isIE = false; // conditional compilation which tells us if this is IE /*@cc_on isIE = true; @*/ // Events to monitor if 'input' event is not supported // The boolean value is whether we have to // re-check after the event with a setTimeout() var events = [ "keyup", false, "blur", false, "focus", false, "drop", true, "change", false, "input", false, "textInput", false, "paste", true, "cut", true,

Categories : Javascript

Event listener for few elements at once
Why not ... var all = [ "#test1", "#test2", "#test3" ]; for (var i = 0; i < all.length; i++) { $(all[i]).on('click', function (event) { doSomething(); }); }

Categories : Jquery

Value of variable to event listener
No need of magic. Better have it globally. title = "Head"; function myfunc(){ console.log(title);//Head document.getElementById("test").onclick = function(){ // you can't have like this console.log(title);//Head } }

Categories : Javascript

in vb.net is there an event listener for clicking outside a button?
You could create a MouseDown-Eventhandler for every Control in your form For Each c As Control In Me.Controls AddHandler c.MouseDown, AddressOf c_MouseDown Next Then check if the sender of the event is not your button Private Sub c_MouseDown(sender As Object, e As MouseEventArgs) If sender Is Button1 Then MsgBox("Open costumized menu") Else MsgBox("Replace this with 'close something'") End If End Sub Edit: Of course you have to create an eventhandler for the form too AddHandler Me.MouseDown, AddressOf c_MouseDown Best to put the handler in the constructor

Categories : Vb.Net

Event listener of multiple events
Your choices are: Use different event handlers. Keep references to the buttons. You may prefer WeakReferences if it is possible for B to outlive the UI. Create a subclass of Button that exposes the difference between them through some property or method. Distinguish the buttons using some existing property of Button. The preferred property for this purpose should be Tag, not Name or Text.

Categories : C#

Add event listener for all radio buttons
In the getView of your listviews adapter create the RadioButton and set the listener. @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); res = inflater.inflate(R.layout.rowview, null); RadioButton radioButton = (TextView)res.findViewById(R.id.radio_view); radioButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub } }); } R.layout.rowview is the view for a single Row in you list view. R.id.radio_view is the id for y

Categories : Android

Hammer.js can't remove event listener
Ok, I figured it out. The source it's simple enough, it's doing: on: function(t, e) { for (var n = t.split(" "), i = 0; n.length > i; i++) this.element.addEventListener(n[i], e, !1); return this },off: function(t, e) { for (var n = t.split(" "), i = 0; n.length > i; i++) this.element.removeEventListener(n[i], e, !1); return this } The thing to note here (apart from a bad documentation) it's that e it's the callback function in the on event, so you're doing: this.element.addEventListener("touch", function() { //your function }, !1); But, in the remove, you don't pass a callback so you do: this.element.removeEventListener("touch", undefined, !1); So, the browser doesn't know witch function are you trying to unbind, you can fix this not using

Categories : Javascript

Event listener when display changes from none to block
The problem is that on.('show' the images are loaded but not yet rendered, therefore $.width and $.height don't provide sizing information. But you can read directly the width and height property of the img DOM element after $(window).load. See the example If you need the images to be rendered and only then you wish to take their rendered sizes, then you should use on('shown'.... Which is only triggered after the tab (containing the images) was shown. I've tried it out and it worked as expected

Categories : Jquery

Add mouse event listener on timeline
If Play_btn is the only child,meaning it's the only thing movClip contains you can replace movClip.Play_btn.addEventListener(MouseEvent.CLICK,playfunc); with movClip.getChildAt(0).addEventListener(MouseEvent.CLICK,playfunc); otherwise try this for (var i:uint = 0; i < movClip.numChildren; i++) { if (movClip.getChildAt(i) is MovieClip) { if (movClip.getChildAt(i).name == "Play_btn") { movClip.Play_btn.addEventListener(MouseEvent.CLICK,playfunc); trace("Play_btn found"); break; } } } function playfunc(evt:MouseEvent) { trace("It works"); SoundMixer.stopAll(); gotoAndPlay(1, "Scene 2"); } UPDATE Be sure that you have named you instance

Categories : Actionscript

Collection add event listener in Backbone
Nope.. When you do a model.save , it will just create a zombie model ( If it not already a part of the collection .i.e If a New model is saved) which is not a part of any collection. So your add event will not be triggered for the collection. If you want the add event to be triggered , Use the create method of collection , which then will know on which collection the new model has to be added.. collection.create({model}); Then it would internally add the model to the collection and fire the add event Also it is a better idea to use listenTo instead of attaching events using on this.listenTo(this.collection, 'add', this.addOne); Code PostsApp.Views.Form = Backbone.View.extend({ template: _.template($('#form-template').html()), render: function () { this.$el.html(t

Categories : Javascript

Adding an event listener to a d3 brush
Getting the event you want might be a bit hairy and require changes to the D3 source code. However, you can use the brushend event together with the methods provided for the brush to figure out whether somebody has clicked on the brush rectangle. var extent = selector.extent(); function bindSelect(){ if(!selector.empty() && !(extent < selector.extent() || extent > selector.extent())) { console.log("foo"); } extent = selector.extent(); } The idea is that if the selection is not empty and the selected extent is the same as it was at the last brushend event, then the user clicked on the selection instead of manipulating it.

Categories : Javascript

How can I check If the event listener is running or not ....?
you can put print on that function to see if the event is trigger look at this code local function doTurn (event) rotatingRect:applyAngularImpulse(50) print("This function is being triggered") end Runtime:addEventListener( "enterFrame", doTurn )

Categories : Lua

keybord interrupt event listener
A simple approach for ending the script with a print could be to wrap the whole script in a try/except block: import sys try: while 1: print 'To infinity and beyond!' # etc etc... except KeyboardInterrupt: print 'Handling the keyboard interrupt...' The interrupt still kills the script, but I would think this is desired behaviour for any user; personally I wouldn't recommend trying to override it.

Categories : Python

Uncaught exception in event listener
When a thread throws an exception that isn't caught, Thread.UncaughtExceptionHandler will be called. If it hasn't been set, the default uncaught exceptionhandler will be called. The handler will display a stacktrace and most likely be restarted, although the documentation doesn't specify what exactly are the steps taken.

Categories : Java

Event Listener or onClick - Best Practice
Hey buddy as rightly told by Sergio. Its better to have event handlers in script element by DOM approach. Now to simplify your task use EVENT DELEGATION just attach document.body.onchange=detect function detect() { var textboxvalue=event.target.value //event.target point to text box on which blur event fires } This simple code will do your task by bubbling of event. No need to use any arrays/conditionals/classes/ids/seperate event handlers "change" event is same as "blur" event ."change" only fires if value of textBox has been changed so null/empty string is not applicable

Categories : Javascript

Event listener for mmenu counter
The plugin will count all LIs (visible or not) that does not have one of these classes: mm-label mm-subtitle mm-noresults mm-noresult The first 3 are used by the plugin for visual purposes, the fourth (mm-noresult) is used to hide it from the search results. So instead of adding display: none, you should add class="mm-noresult". To update the counters, trigger their "count" custom event: $("#menu em").trigger( "count" ); Regards, Fred

Categories : Jquery

Getting this from javascript event listener in backbone.js
you need to use _.bind() to pass a custom context to the callback document.addEventListener('touchstart', _.bind(this.touchstart, this)); document.addEventListener('touchmove', _.bind(this.touchmove, this));

Categories : Javascript

how to attach an event listener using jQuery map v3?
variant #1 (using the addEventListener-method of the plugin) $(function() { $('#map_canvas') .gmap() .bind('init', function(evt, map) { $(map) .addEventListener('dragend',function(){ console.log('a'); }); }); }); variant #2(using the addEventListener-method of the google-Maps-API) $(function() { $('#map_canvas') .gmap() .bind('init', function(evt, map) { google.maps.event.addListener(map,'dragend',function(){ console.log('b'); }); }); });

Categories : Javascript

How to attach an event listener to a javascript var
AFAIK there are no way to add a event listener to the plain object, as it is not placed inside DOM. Events are firing inside DOM, and bubbling so your event listener for custom object won't receive it. There is a http://www.bobjs.com/ framework that can help you implement custom events.

Categories : Javascript

Assign event listener from js class
this in the mouseDown event is not the this of the instance. Try this instead: function myclass() { var _this = this; this.myvar; this.myfunc = function() { alert(this.myvar); document.onmousedown = this.mouseDown; } this.mouseDown = function(e) { alert(_this.myvar); //<<<< } } Demo: http://jsfiddle.net/maniator/E7wK4/1/

Categories : Javascript

Forcing Event Listener in JavaScript
Check out this answer You can use fireEvent on IE, and w3c's dispatchEvent on most other browsers. To create the event you want to fire, you can use either createEvent or createEventObject depending on the browser.

Categories : Javascript

multiple event listener in javascript
Try this: function addMultipleEvents(elements, events){ var tokens = events.split(" "); if(tokens.length == elements.length){ for(var i = 0; i< tokens.length; i++){ elements[i].addEventListener(tokens[i], (e.which == 13 || e.which == 48)?myFunc:); //not myFunc() } } } var textObj = document.getElementById("textId"); var btnObj = document.getElementById("btnId"); addMultipleEvents([textObj,btnObj], 'click keyup'); UPDATE: function addMultipleEvents(elements, events) { var tokens = events.split(" "); if (tokens.length == elements.length) { for (var i = 0; i < tokens.length; i++) { elements[i].addEventListener(tokens[i], myFunc); //not myFunc() } } } var textObj = do

Categories : Javascript

Should I remove listener for SOUND_COMPLETE event?
You're question states my answer for this Everyone says that we should always remove event listeners so that GC could properly collect objects If you are no longer keeping an instance of the Sound object around; then remove the event listener. If you will still be using the Sound object; then there is no need to remove the listener.

Categories : Actionscript

ExtJS 4 - Radiogroup listener event fire
switch statements use strict comparisons in javascript. So you must use strings instead of integers in your cases: case '7': console.log('...'); break;

Categories : Extjs

Custom event listener example in Grails documentation
That looks like it should work, although I'd do it a bit differently. BootStrap.groovy does support dependency injection, so you can inject the grailsApplication bean, but you can also inject eventTriggeringInterceptor directly: class BootStrap { def grailsApplication def eventTriggeringInterceptor def init = { servletContext -> def ctx = grailsApplication.mainContext eventTriggeringInterceptor.datastores.values().each { datastore -> ctx.addApplicationListener new MyPersistenceListener(datastore) } } } Here I still inject grailsApplication but only because I need access to the ApplicationContext to register listeners. Here's my listener (simpler than what the docs claim the simplest implementation would be btw ;) import org.grails.datastor

Categories : Mongodb

Cross browser & IE 8 support event Listener
The problem is when you're calling the fn: FormEnum(). More than likely, you're trying to assign event handlers to forms that don't exist in your DOM. Try putting FormEnum() inside a tag instead. Also, what Vitor said: make sure you're using the declared variable "form" instead of "forms".

Categories : Javascript

Laravel 4 - Logging inside the event listener
Go with monolog, it is widely used and a great library. It can be configured in many different ways and implements the PSR-3 logging interface. See http://laravel.com/docs/errors#logging and http://github.com/Seldaek/monolog‎. Most simple logging command: Log::info('This is some useful information.'); If you want to directly interface with monolog: $monolog = Log::getMonolog(); By using the standard laravel facade for monolog it will automatically log it into a new file with the current date. Regarding your initial query about the easiest method, I feel compelled to say this is the easiest one.

Categories : PHP

PreUpdate event listener crashes the site
You are adding mapping information to your listener which itself is not an entity: /** * @ORMEntity * @ORMHasLifecycleCallbacks */ and ... /** * @ORMPrePersist() * @ORMPreUpdate() */ ... must not be in your listener class. Those annotations can be used in an entity if the entity itself contains i.e. the prePersist methods.

Categories : Symfony2



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.