Yeah I have an idea... I'm going to go see if it works. :)
-- Brandon Aaron On 4/30/07, John Resig <[EMAIL PROTECTED]> wrote:
Excellent Brandon, this is a great start. I suspect that in order to get a full "behavior" plugin (one the feels natural) it'll require a lot of code extensions. Hmm... I wonder if there's anything that can be added to jQuery proper to ease the process. --John On 4/28/07, Brandon Aaron <[EMAIL PROTECTED]> wrote: > > I had some down time this afternoon so I thought I would throw > something together real quick. I just checked it in: > http://dev.jquery.com/browser/trunk/plugins/behavior > > This allows you to register any number of behaviors that will run any > jQuery method/plugin with any number of arguments. It also allows a > plugin developer to register their method so that behavior will auto > run when it is done. It also allows the developer to manually > run/remove a specific behavior or all behaviors. > > It seems to be pretty flexible but with behavior auto running after a > DOM update, I could see it getting pretty out of hand with performance > if lots of behaviors are used. > > > Here is the test/example page that adds three behaviors; an append, > click and addClass. I also remove the addClass behavior before doing > the last two appendTo and prependTo calls. > > http://brandon.jquery.com/plugins/behavior/test/test.html > > -- > Brandon Aaron > > > > On 4/26/07, John Resig <[EMAIL PROTECTED]> wrote: > > > > .behavior() does not exist - but it could (without too much effort) > > the current solution with jQuery is shown in the previous slide (which > > is, unfortunately, rather verbose). I hope that it'll exist one day - > > I probably should've made that more explicit. > > > > You would, "simply", have to override append/prepend/before/after and > > after the injection has occurred, re-run all "behavior"ed expressions. > > Of course, you'd also have to cache all expressions for future use > > (and that's another nut, entirely). If someone feels compelled, you > > can hack on it - otherwise, I may take a stab at it. > > > > --John > > > > On 4/26/07, Starbow <[EMAIL PROTECTED]> wrote: > > > > > > I was just watching the video of John Resig at Yahoo, and in one slide > > > he talked about behaviors, as jquery bindings that act like css rules > > > and apply themselves to html fragments asynchronously loaded into the > > > page. The code sample looked like this: > > > > > > $(document).ready( function() { > > > $('li").behavior( "click", function() { > > > $(this).load("menu.html"); > > > }); > > > }); > > > > > > Is behavior a special jQuery function, something that is in the works, > > > or is it just a regular function and the code for it was missing from > > > the slide set? > > > > > > > > >