event-handling

How does jQuery's new on() method compare to the live() method in performance?

安稳与你 提交于 2019-11-28 12:46:04
jQuery has a new method called on() that is recommended to replace delegate() , live() , and .bind() . For example, using both methods: $('#some-button').on('click', function() { //do something when #some-button is clicked }); $('#some-button').live('click', function() { //do something when #some-button is clicked }); Which one performs better? (I do know that both of these event contexts are at the document level.) jfriend00 As I understand .live() and .on() , the two examples you have included do not so the same thing. Your first one: $('#some-button').on('click', function() { //do something

Java - mouseMoved() event handling in Swing

霸气de小男生 提交于 2019-11-28 12:30:18
I want to listen for mouse movements and clicks in my JFrame. To do this, I've added a MouseListener implemented like this: (whole code of View class is at https://gist.github.com/2837224 , Board class is at https://gist.github.com/2837231 ) class BattleshipsFrame extends JFrame { private final Board playerBoard, opponentBoard; private View view; /** Main window constructor. */ BattleshipsFrame() { ... ... ... //creating and displaying boards playerBoard = new Board(); opponentBoard = new Board(); PlayerBoardListener mouseListener = new PlayerBoardListener(); this.addMouseListener

In SSIS, how do I get the number of rows returned from the Source that SHOULD be processed

让人想犯罪 __ 提交于 2019-11-28 12:24:19
I am working on a project to add logging to our SSIS packages. I am doing my own custom logging by implementing some of the event handlers. I have implemented the OnInformation event to write the time, source name, and message to the log file. When data is moved from one table to another, the OnInformation event will give me a message such as: component "TABLENAME" (1)" wrote 87 rows. In the event that one of the rows fails, and lets say only 85 rows were processed out of the expected 87. I would assume that the above line would read wrote 85 rows . How do I track how many rows SHOULD HAVE

JavaFX: How to make a Node partially mouse transparent?

久未见 提交于 2019-11-28 12:20:15
Simplified Problem: Make one Node "A" that is on top of another Node "B" to be half transparent to MouseEvents, so the Events will reach the underlying Node "B". Both Nodes are of equal size but Node "A" has a half transparent background image so one half of Node "B" is visible. Real Problem: I have a menu of tabs. Each tab can be dragged to expand the corresponding menu layer. Therefore each tab layer is a Pane with a partially transparent background (basically a polygon) of which the transparent part should be also transparent to MouseEvents. The illustration (which I can't post yet, see

jQuery - convert .live() to .on()

梦想与她 提交于 2019-11-28 12:19:21
How do I go about combining this old jQuery code into the v1.7 .on() ? v1.3 .live() : $('#results tbody tr').live({ mouseenter: function () { $(this).find('.popup').show(); }, mouseleave: function () { $(this).find('.popup').hide(); } }); v1.7 .on() : $('#results tbody').on('mouseenter', 'tr', function () { $(this).find('.popup').show(); }); $('#results tbody').on('mouseleave', 'tr', function () { $(this).find('.popup').hide(); }); I want to pass both event handlers to one .on() call, but keep the brilliant event delegation .on() allows me to do. Thank you! You can pass an event-map as the

“after” looping indefinitely: never entering mainloop

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 12:16:31
This is my first post. I started coding when considering a career swap two months ago and am working on a Tetris clone. I've implemented most of the core features, but cannot get the game to refresh continually with an after loop. I'm using Tkinter to produce my Gui and am trying out event oriented programming. My understanding is that after(Time, Event) from Tkinter should schedule whatever the Event callback function is to occur after a delay specified by Time . I think that the code is supposed to continue executing subsequent items after this. My frame refresh function ( game.updateBoard()

Handling click events on z-index'd layers

走远了吗. 提交于 2019-11-28 12:15:52
I have 2 z-index layers in a map application I'm building. I have a problem when I click on the layers to zoom in. The click handler is on the underlying z-index layer and I don't want it to fire when a control in the overlying layer is clicked. The problem i have is that the event gets raised no matter what but the originalTarget property of the event is not the image in the underlying layer when something on the top layer is clicked. Is there anyway to change this? It's called event-bubbling, and you can control it with the event.stopPropagation() method ( event.cancelBubble() in IE). You

wait for document.body existence

前提是你 提交于 2019-11-28 11:27:10
I wrote a chrome extension that works before the page is loaded (using the attribute "run_at": "document_start" ). The problem is that I want to add a div tag to the webpage body as soon as it is created. Before that document.body is null so I can't append tags to it. I don't care about full load of the body, I just need it to be existent. I am trying to find the best way to be alerted when the body tag in html is created (not loaded fully, just created). Is there any event handler for this case that I can write? Also, I don't want to use jQuery or any other non built-in library. Thanks! You

How to handle keypress events in a Qt console application?

有些话、适合烂在心里 提交于 2019-11-28 11:24:33
For example, that when you press "Esc", the application ends. Qt doesn't handle console events, it can just read \n -terminated lines from the console. You need to use native APIs or other libraries (curses). stakasha Here is a workaround for linux. Using these posts Capture characters from standard input without waiting for enter to be pressed https://stackoverflow.com/a/912796/2699984 I've made it like this: ConsoleReader.h #ifndef CONSOLEREADER_H #define CONSOLEREADER_H #include <QThread> class ConsoleReader : public QThread { Q_OBJECT signals: void KeyPressed(char ch); public:

Focus and blur jQuery events not bubbling

人走茶凉 提交于 2019-11-28 11:04:51
With the following html structure: <div> <form><span><input></span></form> </div> <p> and the following jquery code: $('form').on("focus", function(event) { $("p").append("focus no delegation<br>"); }) Why doesn't the focus event ever reach my event handler? Binding the event with a selector parameter works fine: $('form').on("focus", "input", function(event) { $("p").append("focus delegation<br>"); }) Event the next snippet works so the focus event does in fact bubble... $('form').on("focus", "span", function(event) { $("p").append("focus delegation<br>"); }) Both forms work with click and