Prevent onclick action with jQuery

jQuery is not going to solve this one OOTB. It can help, but none of stopPropagation, stopImmediatePropagation, preventDefault, return false will work if you simply attach them to the element. You need to override the element’s click handler. However you state in your question “without removing onclick actions”. So you need to override the default … Read more

Bind event to element using pure Javascript

Here’s a quick answer: document.getElementById(‘anchor’).addEventListener(‘click’, function() { console.log(‘anchor’); }); Every modern browser supports an entire API for interacting with the DOM through JavaScript without having to modify your HTML. See here for a pretty good bird’s eye view: http://overapi.com/javascript

How do I add and remove an event listener using a function with parameters?

Have you tried maintaining a reference to the anonymous function (like you suggested)? So: var listener = function() { check_pos(box); }; window.addEventListener(‘scroll’, listener, false); … window.removeEventListener(‘scroll’, listener, false); Mozilla’s docs suggest the same thing.

Combing an External Event Loop with Qt’s

I haven’t done too much Qt development recently, but if I remember correctly, you can call QApplication::processEvents() within your own event loop (instead of starting the Qt main loop through QApplication::exec()) Edit: I have used the opportunity of a slow Sunday morning to test-drive / learn something about PyQt (Python bindings for Qt) and cobbled … Read more

“select” on multiple Python multiprocessing Queues?

Actually you can use multiprocessing.Queue objects in select.select. i.e. que = multiprocessing.Queue() (input,[],[]) = select.select([que._reader],[],[]) would select que only if it is ready to be read from. No documentation about it though. I was reading the source code of the multiprocessing.queue library (at linux it’s usually sth like /usr/lib/python2.6/multiprocessing/queue.py) to find it out. With Queue.Queue … Read more

How to properly add and use D3 Events?

This question is similar to the one you posted in the d3-js Google Group. Without duplicating what I wrote there, I would reiterate that you probably don’t want d3.dispatch; that is intended for custom event abstractions (such as brushes and behaviors). It’ll be simpler to use native events. If you want your legend to change … Read more