You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Matthias Hryniszak <ma...@hryniszak.de> on 2009/09/23 23:36:17 UTC
Unobtrusive JavaScript
Hi there,
I was wondering if it'd be possible to generate the JavaScript for i.e.
AjaxLink components in such a way that the actual JS is not directly there
as onclick parameter. It's the idea of unobtrusive JavaScript makes the
markup a lot cleaner and easier to read.
A good example of such an unobtrusive JavaScript approach could be observed
in jQuery (http://docs.jquery.com/Events/click):
jQuery([item_selector]).click([handler]);
This binds the onclick event of an element to the given handler without
polluting the actual markup with stuff like
onclick="var
wcall=wicketAjaxGet('?wicket:interface=:0:link_inc::IBehaviorListener:0:',null,null,
function() {return Wicket.$('link__inc1') != null;}.bind(this));return
!wcall;"
which in turn makes reading the generated markup (a bit) harder if there are
lots of those on the page.
Best regards,
Matthias.
Re: Unobtrusive JavaScript
Posted by Matthias Hryniszak <ma...@hryniszak.de>.
That's great! Thanks for the info!
Matthias.
2009/9/24 Igor Vaynberg <ig...@gmail.com>
> this is something planned for 1.5 or 1.6
>
> -igor
>
> On Wed, Sep 23, 2009 at 2:36 PM, Matthias Hryniszak
> <ma...@hryniszak.de> wrote:
> > Hi there,
> >
> > I was wondering if it'd be possible to generate the JavaScript for i.e.
> > AjaxLink components in such a way that the actual JS is not directly
> there
> > as onclick parameter. It's the idea of unobtrusive JavaScript makes the
> > markup a lot cleaner and easier to read.
> >
> > A good example of such an unobtrusive JavaScript approach could be
> observed
> > in jQuery (http://docs.jquery.com/Events/click):
> >
> > jQuery([item_selector]).click([handler]);
> >
> > This binds the onclick event of an element to the given handler without
> > polluting the actual markup with stuff like
> >
> > onclick="var
> >
> wcall=wicketAjaxGet('?wicket:interface=:0:link_inc::IBehaviorListener:0:',null,null,
> > function() {return Wicket.$('link__inc1') != null;}.bind(this));return
> > !wcall;"
> >
> > which in turn makes reading the generated markup (a bit) harder if there
> are
> > lots of those on the page.
> >
> >
> > Best regards,
> > Matthias.
> >
>
Re: Unobtrusive JavaScript
Posted by Igor Vaynberg <ig...@gmail.com>.
this is something planned for 1.5 or 1.6
-igor
On Wed, Sep 23, 2009 at 2:36 PM, Matthias Hryniszak
<ma...@hryniszak.de> wrote:
> Hi there,
>
> I was wondering if it'd be possible to generate the JavaScript for i.e.
> AjaxLink components in such a way that the actual JS is not directly there
> as onclick parameter. It's the idea of unobtrusive JavaScript makes the
> markup a lot cleaner and easier to read.
>
> A good example of such an unobtrusive JavaScript approach could be observed
> in jQuery (http://docs.jquery.com/Events/click):
>
> jQuery([item_selector]).click([handler]);
>
> This binds the onclick event of an element to the given handler without
> polluting the actual markup with stuff like
>
> onclick="var
> wcall=wicketAjaxGet('?wicket:interface=:0:link_inc::IBehaviorListener:0:',null,null,
> function() {return Wicket.$('link__inc1') != null;}.bind(this));return
> !wcall;"
>
> which in turn makes reading the generated markup (a bit) harder if there are
> lots of those on the page.
>
>
> Best regards,
> Matthias.
>