for this talk I'll assume you all know the basics of jQuery and have been using it for DOM manipulation and Ajax calls. I'll show some of the other things in jq that could be labeled as intermediate to advanced. I'll try to highlight anything that is new in 1.7.\n
for this talk I'll assume you all know the basics of jQuery and have been using it for DOM manipulation and Ajax calls. I'll show some of the other things in jq that could be labeled as intermediate to advanced. I'll try to highlight anything that is new in 1.7.\n
I normally don't like presentations that are all about tricks and trips because it's hard to keep track of everything. I'll try to keep the machine gun quiet but I still wanted to highlight a handful of helpful gems in jq.\n
\n
\n
\n
\n
\n
DEMO!\n
\n
DEMO!\n
\n
\n
\n
DEMO!\n
\n
\n
\n
\n
\n
\n
\n
\n
this should be familiar to most of you. The Select() Linq extension does that for IEnumerables in .net. We do the conversion with callback.\n
this should be familiar to most of you. The Select() Linq extension does that for IEnumerables in .net. We do the conversion with callback.\n
But there are a few things to note in the callback function.\n
\n
Event handling is one of the main reasons we use jquery for...\n
It makes it so easy to watch for an event of an element... just choose the element and...\n
Oh, that's that too. It's easy but it takes a little practice to pick the most efficient route. I'm sure a few of us still has to think about it or look up docs to choose the right one for the task.\n
both bind and live allow us to setup handlers for one or many elements in a single command. Select all the elements you want and attach the handler. main diff: dynamically added elements\n
unique elements: elements that don't have a similar purpose with any other element on the page.\n
OK, it was easy to figure out between the previous 2. But those two appear to do the same. Attach a handler for a selector.\nDiff: delegate() attaches a handler to the parent, not Doc. Syntax.\n
\n
on() can also take a data parameter that goes to event.data\n
\n
\n
global events\n
\n
DEMO!\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
DEMO!\n
\n
\n
\n
this is possible way to invoke a callback-based async function... note the two different callbacks, for success and error. note the duplication too.\n
it could get worse. look what would happen if useResult was also async... what if an error happens in useResult? another error callback?\n
see how much cleaner the code becomes when we introduce the deferred task object.\nWe can even subscribe later and it will fire immediately if the task has completed already. DEMO1!\n
the tasks allow us to compose more complicated scenarios without sacrificing too much the read-ability of the code.\n
\n
\n
DEMO2!\n
Internally jQuery can maintain queues of actions. One such queue is the one that allows effects to execute sequentially.\nThe promise command returns a deferred task that resolves when the queue empties.\n
\n
\n
\n
show github, show how files are split, show local repo, build\n