Sure:

$(document).ready(function() {
    Wicket.Event.subscribe('/dom/node/added', function(element) {
        $(element).css('border', '1px solid red');
   });
});


On 19.02.2012 13:39, Jürgen Lind wrote:
I'm not sure if I get you right on this one: the first argument of which
event
handler is the added element? Could you probably add some code to
illustrate this?

J.

On 19.02.2012 13:28, Christoph Leiter wrote:
Hi Juergen,

there's actually no need to scan the full DOM with this method. :) The
first argument of the event handler is the added element. You can simply
use it as is or pass it to $() to do jQuery magic just for the relevant
part.


Christoph


On 19.02.2012 13:18, Jürgen Lind wrote:
Christoph,

I have use yout approach (jQuery + css-class) for some time now as well.
However, I
have found that if the DOM tree grows rather large, a full scan puts
significant load
on the browser. That's why I want to be more specific and limit the
scanning + updating
to the relevant parts of the page.

J.

On 19.02.2012 13:02, Christoph Leiter wrote:
On 18.02.2012 17:46, Jürgen Lind wrote:
thank you for your reply, I did not know that such a method exists
(does
it for 1.4
or is this already Wicket 1.5). An secondly: are these handlers
fired on
a ajax
update of an existing DOM Element or only when it is added?

This is also available in 1.4. The events are fired when you add
something to the ajax request via target.add(Component)

And where would I put the Javascript that registers the handler? In
the
Markup-Page of
the Component? How do I make sure, the handler is added only once?

I use jQuery and register the handler globally in my main.js for every
page within $(document).ready().

This approach works very well if you don't want to create subclasses of
components but rather execute some specific JS if e.g. a css class is
present. I use it to add a hint image to every autocomplete textfield
via jQuery.

If it's more component specific then the renderHead() solution seems
better.


Christoph

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Mit freundlichen Grüßen,

Jürgen Lind


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to