Brandon
This is not something to get into the core, and it's not a replacement for
callbacks.
It's a shortcut for a common type of callbacks that only affect the matched
items and nothing more.
Of course that if you do an ajax request, you'd need the response, or within
an event, you might need to do some operations with the event object.
But sometimes you don't. You just want to say: "load this url into this
object and THEN fade it in".
Or: "When you rollover this element, add X class" and "When you rollout it,
remove the class".
Many people asked for some kind of shortcut for this last situation. The
.hover() + .(add|remove)Class() combination.
Well... for this situation, the syntax is much shorter and easier to read.
It doesn't mean you'll need to find a way to do everything like this. It
means that (if you use the plugin) you'll be able to use a "sweeter" syntax
when suitable.
Cheers
On Sun, Oct 26, 2008 at 8:59 PM, Brandon Aaron <[EMAIL PROTECTED]>wrote:
> Maybe I just like JavaScript but I'd prefer to just pass
> an anonymous function to do what I need within an event handler. Often times
> my event handlers aren't that simple. I can understand queuing chained fx
> methods but this just feels wrong. I'll admit though it is sexy at first and
> an interesting experiment. However, once I start thinking about what my
> existing code would look like in this syntax... it isn't so sexy anymore. We
> would have to start re-creating the core language constructs in our DSL and
> I think JavaScript does a fine job.
> --
> Brandon Aaron
>
>
> On Sun, Oct 26, 2008 at 10:55 AM, Ariel Flesler <[EMAIL PROTECTED]>wrote:
>
>>
>> What do you think of the events part ?
>>
>> $('div')
>> .when('click')
>> .addClass('active')
>> .text('Hey')
>> .done()
>> // Also possible with on()
>> .on('mouseout')
>> .removeClass('active')
>> .text('Ho')
>> .done();
>>
>> At first event handler would only run once, now I improved that. It
>> could also be possible to avoid the use of .done() for successive
>> events. Assuming that you're not going to bind events inside an event
>> handler, but I'm not sure that applies to all cases.
>>
>>
>> --
>> Ariel Flesler
>> http://flesler.blogspot.com/
>>
>> On Oct 23, 9:24 pm, "Ariel Flesler" <[EMAIL PROTECTED]> wrote:
>> > Thanks!!
>> >
>> > I created some more demos, I'm experimenting on different areas :)
>> >
>> >
>> http://test.flesler.com/jquery.async/demos/fx.htmlhttp://test.flesler.com/jquery.async/demos/event.htmlhttp://test.flesler.com/jquery.async/demos/ajax.htmlhttp://test.flesler.com/jquery.async/demos/wait.html
>> >
>> > This is still work in progress.
>> >
>> > Cheers
>> >
>> > On Thu, Oct 23, 2008 at 4:54 PM, Jeffrey Kretz <[EMAIL PROTECTED]
>> >wrote:
>> >
>> >
>> >
>> > > You are a SEXY BEAST!
>> >
>> > > I personally love that implementation.
>> >
>> > > And the syntax of "then" and "meanwhile" is very clear, with a
>> separate
>> > > "wait" method for a delay.
>> >
>> > > JK
>> >
>> > > *From:* [email protected] [mailto:
>> [EMAIL PROTECTED] *On
>> > > Behalf Of *Ariel Flesler
>> > > *Sent:* Thursday, October 23, 2008 10:46 AM
>> > > *To:* [email protected]
>> >
>> > > *Subject:* [jquery-dev] Re: Ultra-Chaining with jQuery
>> >
>> > > Indeed. As I said, I got into making a plugin out of this.
>> > > I changed the semantics, added some features (more to come) and of
>> course,
>> > > implemented it.
>> >
>> > > Here's a very simple demo.
>> > >http://test.flesler.com/jquery.async/
>> >
>> > > Cheers
>> >
>> > > On Thu, Oct 23, 2008 at 2:42 PM, Jeffrey Kretz <[EMAIL PROTECTED]
>> >
>> > > wrote:
>> >
>> > > I tend to agree. But either way, is a wait() function technically
>> feasible?
>> >
>> > > I tried hacking my way though it last night, and couldn't figure out
>> the
>> > > implementation of code that would pause execution while a setInterval
>> > > function did it's work, and only THEN return the "this" jQuery object.
>> >
>> > > Does anyone know how to solve the technical hurdle here?
>> >
>> > > I guess you could call it "asynchronous setInterval"
>> >
>> > > JK
>> >
>> > > -----Original Message-----
>> > > From: [email protected] [mailto:[EMAIL PROTECTED]
>> On
>> > > Behalf Of Bohdan Ganicky
>> > > Sent: Thursday, October 23, 2008 4:07 AM
>> > > To: jQuery Development
>> > > Subject: [jquery-dev] Re: Ultra-Chaining with jQuery
>> >
>> > > HI ricardobeat,
>> >
>> > > I don't think this is a good idea. Most of the time I expect
>> > > everything to happen as fast as possible. Waiting is mostly good for
>> > > animations only and even that's not always true. At least that's how I
>> > > feel it.
>> >
>> > > --
>> > > Bohdan
>> >
>> > > On Oct 23, 2:43 am, ricardobeat <[EMAIL PROTECTED]> wrote:
>> > > > That's exactly what I said the day before, you pratically read my
>> > > > mind :]
>> http://ejohn.org/blog/ultra-chaining-with-jquery/#comment-321336
>> >
>> > > > What about making all methods 'wait' by default? That's what most
>> > > > people expect anyway, people new to jQuery only find out the
>> > > > animations run "in parallel" when they happen to casually chain
>> > > > something with it. Then you could pass a 'skip' argument if you
>> wanted
>> > > > it to run immediatelly. Wouldn't be backwards compatible, but I
>> wonder
>> > > > how many apps would break because of this, haven't seen anyone
>> > > > chaining animation methods.
>> >
>> > > > - ricardo
>> >
>> > > > On 20 out, 14:50, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
>> >
>> > > > > It seems that the tricky part is that the hide() function (as in
>> all
>> > > > > animation functions) use a setInterval, but return the "this"
>> object
>> > > > > immediately.
>> >
>> > > > > Ohhh. I have an idea.
>> >
>> > > > > What if the wait() function set a flag in the object saying this
>> object
>> > > is
>> > > > > waiting for an animation to finish.
>> >
>> > > > > Then, any subsequent jQuery.fn methods that are called get added
>> to a
>> > > queue
>> > > > > to be executed after the animation is finished.
>> >
>> > > > > Once the animation is done, the wait flag is turned off and
>> jQuery.fn
>> > > > > methods are executed immediately as usual.
>> >
>> > > > > So it would look like this:
>> >
>> > > > > jQuery("div").hide("slow")
>> > > > > .wait()
>> > > > > .addClass("done")
>> > > > > .find("span")
>> > > > > .addClass("done")
>> > > > > .end()
>> > > > > .show("slow")
>> > > > > .wait()
>> > > > > .removeClass("done")
>> > > > > .find("span")
>> > > > > .removeClass("done");
>> >
>> > > > > JK
>> >
>> > > > > -----Original Message-----
>> > > > > From: [email protected] [mailto:
>> [EMAIL PROTECTED]
>> > > On
>> >
>> > > > > Behalf Of nikomomo
>> > > > > Sent: Monday, October 20, 2008 1:01 AM
>> > > > > To: jQuery Development
>> > > > > Subject: [jquery-dev] Re: Ultra-Chaining with jQuery
>> >
>> > > > > First, you can do that with the callback parameter.
>> >
>> > > > > jQuery("div").hide("slow")
>> > > > > .wait()
>> > > > > .addClass("done")
>> > > > > .find("span")
>> > > > > .addClass("done")
>> > > > > .end()
>> > > > > .show("slow", function() {
>> > > > > $(this).removeClass("done");
>> > > > > })
>> >
>> > > > > But to create a wait() function, I think you have to create a
>> lock/
>> > > > > semaphore (a simple counter), incremented in jQuery.anime (or
>> anything
>> > > > > that create a timer callback?), decremented at the end of the
>> anime,
>> > > > > and tested in the wait() function.
>> >
>> > > > > On 20 oct, 00:29, "Jeffrey Kretz" <[EMAIL PROTECTED]> wrote:
>> > > > > > That's an interesting idea -- personally I like this syntax a
>> lot.
>> >
>> > > > > > But because javascript isn't a true multithreading environment,
>> I
>> > > wonder
>> > > > > if
>> > > > > > this would be possible at all.
>> >
>> > > > > > It's not like the wait() function can detect for the existence
>> of an
>> > > > > > animation, pause execution until the animation is done, and only
>> then
>> > > > > return
>> > > > > > the "this" object.
>> >
>> > > > > > Does anyone know if there's a way to create such behavior?
>> >
>> > > > > > JK
>> >
>> > > > > > -----Original Message-----
>> > > > > > From: [email protected] [mailto:
>> > > [EMAIL PROTECTED]
>> > > On
>> >
>> > > > > > Behalf Of xwisdom
>> > > > > > Sent: Sunday, October 19, 2008 12:43 PM
>> > > > > > To: jQuery Development
>> > > > > > Subject: [jquery-dev] RE: Ultra-Chaining with jQuery
>> >
>> > > > > > Sorry Guys but I could not find the thread mentioned on John's
>> > > > > > website:http://ejohn.org/blog/ultra-chaining-with-jquery/
>> >
>> > > > > > Anyway, the chaining system looks ok but rather than using a
>> chain()
>> > > > > > metod how about using a wait() method that would block or
>> process
>> > > > > > succeeding calls after the preceding call has been completed:
>> >
>> > > > > > jQuery("div").hide("slow")
>> > > > > > .wait()
>> > > > > > .addClass("done")
>> > > > > > .find("span")
>> > > > > > .addClass("done")
>> > > > > > .end()
>> > > > > > .show("slow")
>> > > > > > .wait()
>> > > > > > .removeClass("done")
>> >
>> > > > > > Just my 2cents
>> >
>> > > --
>> > > Ariel Flesler
>> > >http://flesler.blogspot.com
>> >
>> > --
>> > Ariel Fleslerhttp://flesler.blogspot.com
>>
>>
>
> >
>
--
Ariel Flesler
http://flesler.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---