Any examples of event-based jQuery programming structure?

I've built a program that I think could benefit from a shift toward using jQuery's events (bind() and trigger()) instead of the typical function-calling programming structure. For example, instead of:

//device changed //(diffs holds key: {old_val: 'old value', new_val: 'new value'} pairs) DEVICES.update(device, diffs) DIAGRAM.update(device, diffs) TABLES.update(DEVICES.$table, device, diffs) /* ... */ //device changed - some other code location DEVICES.update(device, diffs); DIAGRAM.update(device, diffs); TABLES.update(DEVICES.$table, device, diffs);

I could write:

//DEVICES.update(), DIAGRAM.update, and TABLES.update have all been bound to //DEVICES.$container's device_changed custom event (in their respective modules) //device changed //(diffs holds key: {old_val: 'old value', new_val: 'new value'} pairs) DEVICES.$container.trigger('device_changed', [device, diffs]); /* ... */ //device changed - some other code location DEVICES.$container.trigger('device_changed', [device, diffs]);

I'm learning how to use bind() and trigger() effectively, but mostly just making it up as I go along. Are there any good examples of how to program/structure code following this event-driven style with jQuery?

Category:jquery Views:0 Time:2011-10-24

Related post

  • event based socket programming in C 2012-04-05

    when the call to select statement returns , we check for the active file descriptors to process the multiple client's request. select(maxfd+1, &readfds, NULL, NULL, NULL); That , is select command monitors the file descriptors in the readfds set.

  • Is network event based programming really better-? 2011-03-21

    With event based programming you essentially just loop and poll, loop and poll...why is this preferred to just blocking? If you're not receiving any events why would you prefer to use select() over just blocking on an accept()? --------------Solution

  • Is there a rigorous general introduction to event-based programming in textbook or monograph form? 2009-08-10

    I've been looking at the selection on Amazon and "The Power of Events: An Introduction to Complex Event Processing in Distributed Enterprise Systems" sounds like it has way too much fluff, but the other choices like: "Event-Based Programming: Taking

  • paper on event-based v.s. threaded programing 2010-08-17

    I am trying to tap into the stackoverflow community to aid my fogged memory. A while ago I have read a research paper regarding multithreading v.s. event-base programming paradigm. The thesis is to challenge the current belief that multithreading has

  • Is Lua an event-based programming language? 2011-05-31

    Is Lua event-based or thread-based? I've been reading a lot about Node.js lately, and it appears that one of the the largest selling points for it is related to it being event-based as opposed to thread-based. What is Lua? --------------Solutions----

  • Metrics for comparing event-based and thread-based programming models 2011-06-21

    I have been asked to compare the programming models used by two different OSs for wireless sensor networks, TinyOS (which uses an event-based model) and Contiki (which uses events internally, but offers a protothread model for application programmers

  • JQuery - Call the jquery button click event based on name property 2012-03-14

    I have one HTML button like, <input type="button" id="btnSubmit" name="btnName" class="btnclass" value="Click Me" /> I want to call jquery button click event based on "id" property means, we use the code like, $("#btnSubmit").click(function(){

  • code reuse with event based programming in extjs4 mvc 2011-09-10

    I have a wizard with each step a form. On click of next wizard calls form.validate() and then switches to the next card. Validate does all sorts of business validation + basic form validation. I have an abstract superclass for all the forms that just

  • Node.js event vs thread programming on server side 2011-01-02

    We are planning to start a fairly complex web-portal which is expected to attract good local traffic and I've been told by my boss to consider/analyse node.js for the serve side. I think scalability and multi-core support can be handled with an Nginx

  • Event based mysql for php socket? 2011-12-13

    I have a web client that i coded in php/html/javascript/jquery. My client fetches through javascript (in post) data from a mysql server through a php script. I know i could make a php socket server running on that php-apache-mysql box but how do i te

  • How does one unit test sections of code that are procedural or event-based 2008-09-16

    I'm convinced from this presentation and other commentary here on the site that I need to learn to Unit Test. I also realize that there have been many questions about what unit testing is here. Each time I go to consider how it should be done in the

  • Event-based async in C#; any generic refactoring possible? 2008-10-29

    Some APIs, like the WebClient, use the Event-based Async pattern. While this looks simple, and probably works well in a loosely coupled app (say, BackgroundWorker in a UI), it doesn't chain together very well. For instance, here's a program that's mu

  • Why are event-based network applications inherently faster than threaded ones? 2008-11-14

    We've all read the benchmarks and know the facts - event-based asynchronous network servers are faster than their threaded counterparts. Think lighttpd or Zeus vs. Apache or IIS. Why is that? --------------Solutions------------- I think event based v

  • Rebinding events in jQuery after Ajax update (updatepanel) 2008-11-19

    I have several input and option elements on my page, each (well almost) have an event attached to update some text on the page once they change. I use jQuery which is really really cool :) I also use Microsofts Ajax framework, utilizing the UpdatePan

  • Pattern for wiring up events using jQuery 2009-05-06

    Please look at the code at the end to see the method I've been using to wire up events in my jQuery code. I prefer using bind and as you can also see I don't like using Anonymous functions in my event handlers. I'm using named functions because of th

  • How to represent an event based architecture in a static UML model? 2009-07-13

    I have a fairly basic C# event based system but I'm not sure how I model it in UML. I obviosuly want to show the event publisher, subscriber, handlers and EventArgs classes .. I think you use 'signals' but I can't find any examples. Can anyone point

  • Game programming structure 2009-10-24

    I've been programming in c++ for a bit now and Im very familiar with the syntax. I'm trying to use Allegro to make a card game. I understand everything I need to do for the game logic and what not. What puzzles me is how to drive the game. I'm sort o

  • What is the state of C10K-like event-based server development in TCL? 2010-01-24

    TCL is a nice simple programming language, but does not seem to get the credit and/or respect it deserves. I learned it back in 1995 in college and promptly forgot about it only to stumble upon it again recently. I am mostly interested TCL for develo

  • How can i check if key is pressed during click event with jquery? 2010-03-15

    I would like to catch a click event with jquery and be able to tell if a key was pressed at the same time so I can fork within the callback function based on the keypress event. For example: $("button").click(function() { if([KEYPRESSED WHILE CLICKED

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.107 (s). 11 q(s)