> want to not output the list with wicket's ordinary ajax replace method?
hmmm... wicket's ordinary ajax replace method?
the basic problem here is:
-when the page is first rendered, the following is added to the dom
(it's the behaviour responsible for this):
$('#numberOfCommentsLink24').click(function() {
$('#listOfCommentsContainer25').slideToggle(450); })
-when i click on the "trigger" link (numberOfCommentsLink24) i fire an
ajax request, and add a webmarkupcontainer (listOfCommentsContainer25)
i want to "refresh":
target.addComponent(listOfCommentsContainer);
-the ajax response is: *not only* the updated
listOfCommentsContainer25, but *also* an <evaluate> section in the
ajax response, that includes:
$('#numberOfCommentsLink24').click(function() {
$('#listOfCommentsContainer25').slideToggle(450); })
(of course, because the behaviour has been added to the
listOfCommentsContainer).
-... that means, i now have loaded in the dom *twice* :
$('#numberOfCommentsLink24').click(function() {
$('#listOfCommentsContainer25').slideToggle(450); })
so with *one* click on the numberOfCommentsLink24 , i get *two* calls
to $('#listOfCommentsContainer25').slideToggle(450);
which basically slides up, and immediately down. that is, slide toggle
means it goes up (hides) if it was down (visible), it goes down
(shows) if it was up (hidden).
i want to avoid this behaviour by stopping the ajax response from
spitting back the javascript code for a second time. perhaps do
something inside the behaviour class?
hope it clarifies! thanks,
francisco
On Thu, Nov 6, 2008 at 1:53 PM, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]> wrote:
> Im not sure I understand then..? Could you explain another way? You would
> want to not output the list with wicket's ordinary ajax replace method?
>
> francisco treacy wrote:
>>
>> yes, i'm aware of those. but i'd want to 'remove' things from the
>> ajaxRequestTarget rather than append...
>>
>> or, some way of attaching/executing behaviours only once?
>>
>>
>> On Thu, Nov 6, 2008 at 12:58 PM, Nino Saturnino Martinez Vazquez Wael
>> <[EMAIL PROTECTED]> wrote:
>>
>>>
>>> theres a prepend / append js on ajaxRequestTarget, that should work...
>>>
>>> francisco treacy wrote:
>>>
>>>>
>>>> hi,
>>>>
>>>> we're using a home-grown wrapper for integrating jquery into wicket -
>>>> specifically for jquery effects.
>>>>
>>>> and i'm having some trouble with ajax updates. i'll explain with an
>>>> example:
>>>>
>>>>
>>>> final WebMarkupContainer listOfCommentsContainer = new
>>>> WebMarkupContainer("listOfCommentsContainer");
>>>> listOfCommentsContainer.setOutputMarkupId(true);
>>>> add(listOfCommentsContainer);
>>>>
>>>> AjaxLink<Void> numberOfCommentsLink = new
>>>> AjaxLink<Void>("numberOfCommentsLink") {
>>>> @Override
>>>> public void onClick(AjaxRequestTarget target) {
>>>>
>>>> target.addComponent(listOfCommentsContainer);
>>>> }
>>>> };
>>>>
>>>> listOfCommentsContainer.add(new JQueryEffectBehavior(new
>>>> SlideToggleEffect(), numberOfCommentsLink));
>>>>
>>>> add(numberOfCommentsLink);
>>>>
>>>> this code is basically outputting something like:
>>>>
>>>> <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
>>>> Wicket.Event.add(window, "domready", function() {
>>>> $('#numberOfCommentsLink24').click(function() {
>>>> $('#listOfCommentsContainer25').slideToggle(450); }) ;});
>>>> /*-->]]>*/</script>
>>>>
>>>> listOfCommentsContainer25 being the target container to slide,
>>>> numberOfCommentsLink24 the trigger.
>>>>
>>>> this works fine per se. now when i click on numberOfCommentsLink24 ,
>>>> my list is refreshed (added it to the ajaxrequesttarget) and the
>>>> effect behaviour outputting javascript code again...
>>>>
>>>> <ajax-response><header-contribution><![CDATA[<head
>>>> xmlns:wicket="http://wicket.apache.org"><script type="text/javascript"
>>>>
>>>>
>>>> src="resources/hub.app.wicket.components.jquery.JQueryResourceReference/jquery-1.2.6.js"></script>
>>>> <script type="text/javascript"
>>>>
>>>>
>>>> src="resources/hub.app.wicket.components.jquery.JQueryEffectCoreResourceReference/jquery-1.2.6.effects.core.js"></script>
>>>> </head>]]></header-contribution>
>>>> (...)
>>>> <evaluate><![CDATA[$('#numberOfCommentsLink24').click(function() {
>>>> $('#listOfCommentsContainer25').slideToggle(450); })
>>>> ]]></evaluate></ajax-response>
>>>>
>>>> which means that i can visually perceive a very quick slideDown
>>>> followed by a slideUp (this is the normal slideToggle functionality).
>>>>
>>>> is there a way not to include the <evaluate> part? or detect if the
>>>> component has already been rendered in markup to check whether to
>>>> execute the behaviour again?
>>>> perhaps i'm missing some basic point here... any suggestions?
>>>>
>>>> thanks in advance,
>>>>
>>>> francisco
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>>>
>>>
>>> --
>>> -Wicket for love
>>>
>>> Nino Martinez Wael
>>> Java Specialist @ Jayway DK
>>> http://www.jayway.dk
>>> +45 2936 7684
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]