Re: Ajax behavior for JavaScript event delegation

2013-08-01 Thread Martin Grigorov
On Wed, Jul 31, 2013 at 3:04 PM, Martin Grigorov wrote: > Hi Sebastien, > > > On Wed, Jul 31, 2013 at 2:37 PM, Sebastien wrote: > >> Hi, >> >> I agree with Igor. Just have to take care that binding to document is not >> a >> default behavior for all bound events, and that it should be use with >>

Re: Ajax behavior for JavaScript event delegation

2013-07-31 Thread Sebastien
Hi Martin > I think Igor said the opposite - bind on document with child selector: > $(document).on('click', '[data-w-click]', handler); I probably miss something somewhere in the explanation, then... Sorry for the confusion! > Behavior#bind(Component) gives you a reference to the component. No

Re: Ajax behavior for JavaScript event delegation

2013-07-31 Thread Martin Grigorov
Hi Sebastien, On Wed, Jul 31, 2013 at 2:37 PM, Sebastien wrote: > Hi, > > I agree with Igor. Just have to take care that binding to document is not a > default behavior for all bound events, and that it should be use with care. > I think Igor said the opposite - bind on document with child sel

Re: Ajax behavior for JavaScript event delegation

2013-07-31 Thread Sebastien
Hi, I agree with Igor. Just have to take care that binding to document is not a default behavior for all bound events, and that it should be use with care. (IMHO, the javadoc should be enough) Martin, I unfortunately did not had the chance to have a look at your code now... :s But, if it not the c

Re: Ajax behavior for JavaScript event delegation

2013-07-30 Thread Igor Vaynberg
binding on document is fine, you just have to make sure your code is fast in case you are binding to things like mousemove. -igor On Tue, Jul 30, 2013 at 1:31 AM, Martin Grigorov wrote: > On Fri, Jul 12, 2013 at 5:21 PM, Igor Vaynberg >wrote: > > > On Fri, Jul 12, 2013 at 1:50 AM, Martin Grigo

Re: Ajax behavior for JavaScript event delegation

2013-07-30 Thread Martin Grigorov
On Fri, Jul 12, 2013 at 5:21 PM, Igor Vaynberg wrote: > On Fri, Jul 12, 2013 at 1:50 AM, Martin Grigorov > wrote: > > On Fri, Jul 12, 2013 at 8:59 AM, Igor Vaynberg >wrote: > > > >> On Thu, Jul 11, 2013 at 7:22 AM, Martin Grigorov > >> wrote: > >> > On Thu, Jul 11, 2013 at 4:48 PM, Sven Meier

Re: Ajax behavior for JavaScript event delegation

2013-07-12 Thread Igor Vaynberg
On Fri, Jul 12, 2013 at 1:50 AM, Martin Grigorov wrote: > On Fri, Jul 12, 2013 at 8:59 AM, Igor Vaynberg wrote: > >> On Thu, Jul 11, 2013 at 7:22 AM, Martin Grigorov >> wrote: >> > On Thu, Jul 11, 2013 at 4:48 PM, Sven Meier wrote: >> > >> >> Hi, >> >> >> >> >> >> >The idea with plain JS solutio

Re: Ajax behavior for JavaScript event delegation

2013-07-12 Thread Sven Meier
I'm still sceptical about this feature: IMHO event delegation is a delegate tool and you cannot insert it transparently: No one in the JavaScript world would try to do it that way. When you start thinking about JavaScript performance of your event handlers you probably have a huge table in yo

Re: Ajax behavior for JavaScript event delegation

2013-07-12 Thread Martin Grigorov
On Fri, Jul 12, 2013 at 8:59 AM, Igor Vaynberg wrote: > On Thu, Jul 11, 2013 at 7:22 AM, Martin Grigorov > wrote: > > On Thu, Jul 11, 2013 at 4:48 PM, Sven Meier wrote: > > > >> Hi, > >> > >> > >> >The idea with plain JS solution I cannot visualize in my head yet. > >> > >> EventDelegatingBehavi

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Igor Vaynberg
On Thu, Jul 11, 2013 at 7:22 AM, Martin Grigorov wrote: > On Thu, Jul 11, 2013 at 4:48 PM, Sven Meier wrote: > >> Hi, >> >> >> >The idea with plain JS solution I cannot visualize in my head yet. >> >> EventDelegatingBehavior is just a collector of JavaScript snippets. The >> actual magic runs in

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Cedric Gatay
I'd prefer using a data-delegated attribute than setting a special css class on items. In my opinion, css classes should not reflect business considerations, that's where data-* attributes are useful. __ Cedric Gatay (@Cedric_Gatay ) http://code-troopers.com | http

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Sven Meier
bind on document, and it was slow. Sure, the higher you register a delegating event handler in the markup tree, the slower it is. The same holds for using event delegation on a table with a deeply nested cell structure. Sven On 07/11/2013 04:54 PM, Martin Grigorov wrote: On Thu, Jul 11, 2

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Martin Grigorov
On Thu, Jul 11, 2013 at 5:22 PM, Martin Grigorov wrote: > > > > On Thu, Jul 11, 2013 at 4:48 PM, Sven Meier wrote: > >> Hi, >> >> >> >The idea with plain JS solution I cannot visualize in my head yet. >> >> EventDelegatingBehavior is just a collector of JavaScript snippets. The >> actual magic ru

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Martin Grigorov
On Thu, Jul 11, 2013 at 4:48 PM, Sven Meier wrote: > Hi, > > > >The idea with plain JS solution I cannot visualize in my head yet. > > EventDelegatingBehavior is just a collector of JavaScript snippets. The > actual magic runs in the browser: a custom bubbling of events and > delegation to the ac

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Sven Meier
Hi, >The idea with plain JS solution I cannot visualize in my head yet. EventDelegatingBehavior is just a collector of JavaScript snippets. The actual magic runs in the browser: a custom bubbling of events and delegation to the actual behavior. It should be possible to do this plain with Java

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Martin Grigorov
On Thu, Jul 11, 2013 at 4:30 PM, Nick Pratt wrote: > I think this is great - we have some tables now with a ton of JS events on > the child elements. Just to clarify, will this make the rendered page > smaller since there will only be a single JS handler for the event for the > container rather

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Sven Meier
Just to clarify, will this make the rendered page smaller ... ? Very slightly only :( Sven On 07/11/2013 03:30 PM, Nick Pratt wrote: I think this is great - we have some tables now with a ton of JS events on the child elements. Just to clarify, will this make the rendered page smaller since

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Nick Pratt
I think this is great - we have some tables now with a ton of JS events on the child elements. Just to clarify, will this make the rendered page smaller since there will only be a single JS handler for the event for the container rather than N JS handlers? Making it switchable (I think how Sven s

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Sven Meier
> Thanks for reading! How about making the whole thing a little more 'pluggable'? // AjaxEventBehavior public void renderHead(final Component component, final IHeaderResponse response) { super.renderHead(component, response); if (component.isEnabledInHierarchy())

Re: Ajax behavior for JavaScript event delegation

2013-07-11 Thread Cedric Gatay
I find this is a great idea. We often use data tables with a lot of ajax behaviors, with this kind of behavior it should speed it up. I will try to test it in the coming days. __ Cedric Gatay (@Cedric_Gatay ) http://code-troopers.com | http://www.bloggure.info | ht