I can't see a solution for what you are doing.

    ...
    @Override
    public void onClick(AjaxRequestTarget target) {
        Panel panel = new MyPanel("panelId");
        addOrReplace(panel);
        target.addComponent(panel);
    }

creates a NEW Panel and the NEW panel is a totally new object that does not 
know anything about the ORIGINAL Panel. The AJAX response renders the NEW Panel 
(with it's new class attribute but without the AJAX behaviors you've added to 
the ORIGINAL Panel).

This also happens with Wickts builtin Behaviors. Try this

                panel.add(new AjaxEventBehavior("onclick") {
                        @Override
                        protected void onEvent(AjaxRequestTarget target) {
                                System.out.println("clicked!");
                        }
                });

This also disappears after you replace the panel within an AJAX call.


You can do two things:
1.  ...
    @Override
    public void onClick(AjaxRequestTarget target) {
        Panel panel = new MyPanel("panelId");
!       panel.add(new DraggableBehavior());
        addOrReplace(panel);
        target.addComponent(panel);
    }

!   AND USE VERSION 0.3.5!

2.  ...
    @Override
    public void onClick(AjaxRequestTarget target) {
!       originalPanel.setDefaultModelObject(some new value);
!       target.addComponent(originalPanel);
    }

Good luck and let me know if it works for you!

Stefan

-----Ursprüngliche Nachricht-----
Von: Stefan Jozsa [mailto:stefan_...@yahoo.com] 
Gesendet: Donnerstag, 18. Juni 2009 13:24
An: users@wicket.apache.org
Betreff: Re: WicketJQuery: Drag & drop behavior lost for components of AJAX 
updated panels


Found that when panel is constructed like:
    public MyPage() {
        ...
        add(new MyPanel("panelId"));
        ...
    }
markup of a draggable element is:
<span id="id123456" class="myClass ui-draggable" ... >[]</span>

However when:
    ...
    @Override
    public void onClick(AjaxRequestTarget target) {
        Panel panel = new MyPanel("panelId");
        addOrReplace(panel);
        target.addComponent(panel);
    }
markup of a draggable element is:
<span id="id123456" class="myClass" ... >[]</span>

that is 'ui-draggable' is not found (stripped ? not added?) 
in 'class' attribute of draggable element.

Any help is welcommed,
Stefan


--- On Thu, 6/18/09, Stefan Jozsa <stefan_...@yahoo.com> wrote:

> From: Stefan Jozsa <stefan_...@yahoo.com>
> Subject: WicketJQuery: Drag & drop behavior lost for components of AJAX 
> updated panels
> To: users@wicket.apache.org
> Date: Thursday, June 18, 2009, 1:44 PM
> 
> Doing:
>     public MyPage() {
>         ...
>         add(new MyPanel("panelId"));
>         ...
>     }
> dragging elements (having DraggableBehavior) of 'MyPanel'
> works.
> 
> However doing:
>     ...
>     @Override
>     public void onClick(AjaxRequestTarget target)
> {
>         Panel panel = new
> MyPanel("panelId");
>         addOrReplace(panel);
>         target.addComponent(panel);
>     }
>     
> dragging elements of 'MyPanel' DO NOT works
> (DraggableBehavior is lost).
> 
> 
> What's going on ?
> Any help is (very) appreciated,
> thanks Stefan
> 
> Using:
> Wicket-1.4.rc4,
> WicketJQuery-0.3.4
> 
> 
> 
> 
>       
> 
> ---------------------------------------------------------------------
> 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


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

Reply via email to