You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by francisco treacy <fr...@gmail.com> on 2008/11/06 12:36:49 UTC

avoid ajax response evaluate javascript

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: avoid ajax response evaluate javascript

Posted by francisco treacy <fr...@gmail.com>.
thanks for the hint, martin.

ServletWebRequest request = (ServletWebRequest) RequestCycle.get().getRequest();
		
if (!request.isAjax()) {
	response.renderJavascriptReference(new JQueryEffectCoreResourceReference());
	(...)
}

in renderHead() seems to do the trick.

francisco


On Thu, Dec 4, 2008 at 12:56 PM, Martin Makundi
<ma...@koodaripalvelut.com> wrote:
> There is ServletWebRequest.isAjax
>
> **
> Martin
>
> 2008/12/4 francisco treacy <fr...@gmail.com>:
>> i've been using the aforementioned toggle behavior almost always in
>> ajaxy pages, and in that case they work fine.
>>
>> basically that means i add toggle behaviors to components in a page.
>> when i call an ajax link, toggle works ok  because the isTemporary()
>> method of the behavior returns *true* (otherwise it would attach the
>> toggle effect contribution to the <header-contribution> part of the
>> response and it would blow things up - i.e. triggering more than once
>> a certain toggle effect).
>>
>> however, i now started using that in pages that use normal links (not
>> ajax). so when i get the (non ajax) response for the linked page, as
>> the behavior is temporary, it won't contribute to the header anymore.
>> thus breaking the effect.
>>
>> say page1 links to page1b [a new version of page1] when i "diff page1
>> page1b " i roughly get this:
>>
>> 24,28d23
>> < <script type="text/javascript"
>> src="resources/myapp.wicket.components.jquery.JQueryEffectCoreResourceReference/jquery-1.2.6.effects.core.js"></script>
>> < <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
>> < Wicket.Event.add(window, "domready", function() {
>> $('#optionalInfoLink58').click(function() {
>> $('#OptionalInfoArea59').slideToggle(450); }) ;});
>> < /*-->]]>*/</script>
>>
>> i.e. the toggle effect won't work in page1b because "function() {
>> $('#optionalInfoLink58').click(function() {
>> $('#OptionalInfoArea59').slideToggle(450); }) ;}" is not present in
>> that page at all. note this doesn't pose a problem if i refresh
>> certain components via ajax because the original page still contains
>> this "javascript listener" in the header.
>>
>> my question: is there a way to tell inside isTemporary() whether the
>> request was ajax or normal, to return true or false according to that?
>> other suggestions?
>>
>> francisco
>>
>>
>> On Thu, Nov 6, 2008 at 2:45 PM, francisco treacy
>> <fr...@gmail.com> wrote:
>>>> It did.. You could try the isTemporary (return true) on the behavior, it
>>>
>>> thanks nino... that *is* the solution, works like a charm
>>>
>>> my mistake for not paying attention to the last bits of the javadoc
>>> ibehavior page :)
>>>
>>> "boolean isTemporary()
>>>
>>>    Specifies whether or not this behavior is temporary. Temporary
>>> behaviors are removed at the end of request. Such behaviors are useful
>>> for modifying component rendering only when it renders next. Usecases
>>> include javascript effects, initial clientside dom setup, etc. "
>>>
>>> ... couldn't be more clear...
>>>
>>> cheers,
>>>
>>> francisco
>>>
>>> On Thu, Nov 6, 2008 at 2:22 PM, Nino Saturnino Martinez Vazquez Wael
>>> <ni...@jayway.dk> wrote:
>>>> Hi Francisco
>>>>
>>>> It did.. You could try the isTemporary (return true) on the behavior, it
>>>> could mean that it will only add the behavior for that request, but I am not
>>>> sure.. Or you could try creating a new markupcontainer
>>>> (listOfCommentsContainer), it'll give it a new id..
>>>>
>>>> Or you could stuff in some logic as a ajaxcalldecorator on your link, that
>>>> will clean it up in pure js...
>>>>
>>>> I had some difficulties with exactly this when I did the wicket reaction
>>>> game.
>>>>
>>>> I hope this helpes..
>>>>
>>>> francisco treacy wrote:
>>>>>>
>>>>>> 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
>>>>> <ni...@jayway.dk> 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
>>>>>>> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> -Wicket for love
>>>>>>>>
>>>>>>>> Nino Martinez Wael
>>>>>>>> Java Specialist @ Jayway DK
>>>>>>>> http://www.jayway.dk
>>>>>>>> +45 2936 7684
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> -Wicket for love
>>>>>>
>>>>>> Nino Martinez Wael
>>>>>> Java Specialist @ Jayway DK
>>>>>> http://www.jayway.dk
>>>>>> +45 2936 7684
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> --
>>>> -Wicket for love
>>>>
>>>> Nino Martinez Wael
>>>> Java Specialist @ Jayway DK
>>>> http://www.jayway.dk
>>>> +45 2936 7684
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: avoid ajax response evaluate javascript

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
There is ServletWebRequest.isAjax

**
Martin

2008/12/4 francisco treacy <fr...@gmail.com>:
> i've been using the aforementioned toggle behavior almost always in
> ajaxy pages, and in that case they work fine.
>
> basically that means i add toggle behaviors to components in a page.
> when i call an ajax link, toggle works ok  because the isTemporary()
> method of the behavior returns *true* (otherwise it would attach the
> toggle effect contribution to the <header-contribution> part of the
> response and it would blow things up - i.e. triggering more than once
> a certain toggle effect).
>
> however, i now started using that in pages that use normal links (not
> ajax). so when i get the (non ajax) response for the linked page, as
> the behavior is temporary, it won't contribute to the header anymore.
> thus breaking the effect.
>
> say page1 links to page1b [a new version of page1] when i "diff page1
> page1b " i roughly get this:
>
> 24,28d23
> < <script type="text/javascript"
> src="resources/myapp.wicket.components.jquery.JQueryEffectCoreResourceReference/jquery-1.2.6.effects.core.js"></script>
> < <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
> < Wicket.Event.add(window, "domready", function() {
> $('#optionalInfoLink58').click(function() {
> $('#OptionalInfoArea59').slideToggle(450); }) ;});
> < /*-->]]>*/</script>
>
> i.e. the toggle effect won't work in page1b because "function() {
> $('#optionalInfoLink58').click(function() {
> $('#OptionalInfoArea59').slideToggle(450); }) ;}" is not present in
> that page at all. note this doesn't pose a problem if i refresh
> certain components via ajax because the original page still contains
> this "javascript listener" in the header.
>
> my question: is there a way to tell inside isTemporary() whether the
> request was ajax or normal, to return true or false according to that?
> other suggestions?
>
> francisco
>
>
> On Thu, Nov 6, 2008 at 2:45 PM, francisco treacy
> <fr...@gmail.com> wrote:
>>> It did.. You could try the isTemporary (return true) on the behavior, it
>>
>> thanks nino... that *is* the solution, works like a charm
>>
>> my mistake for not paying attention to the last bits of the javadoc
>> ibehavior page :)
>>
>> "boolean isTemporary()
>>
>>    Specifies whether or not this behavior is temporary. Temporary
>> behaviors are removed at the end of request. Such behaviors are useful
>> for modifying component rendering only when it renders next. Usecases
>> include javascript effects, initial clientside dom setup, etc. "
>>
>> ... couldn't be more clear...
>>
>> cheers,
>>
>> francisco
>>
>> On Thu, Nov 6, 2008 at 2:22 PM, Nino Saturnino Martinez Vazquez Wael
>> <ni...@jayway.dk> wrote:
>>> Hi Francisco
>>>
>>> It did.. You could try the isTemporary (return true) on the behavior, it
>>> could mean that it will only add the behavior for that request, but I am not
>>> sure.. Or you could try creating a new markupcontainer
>>> (listOfCommentsContainer), it'll give it a new id..
>>>
>>> Or you could stuff in some logic as a ajaxcalldecorator on your link, that
>>> will clean it up in pure js...
>>>
>>> I had some difficulties with exactly this when I did the wicket reaction
>>> game.
>>>
>>> I hope this helpes..
>>>
>>> francisco treacy wrote:
>>>>>
>>>>> 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
>>>> <ni...@jayway.dk> 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
>>>>>> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> -Wicket for love
>>>>>>>
>>>>>>> Nino Martinez Wael
>>>>>>> Java Specialist @ Jayway DK
>>>>>>> http://www.jayway.dk
>>>>>>> +45 2936 7684
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> -Wicket for love
>>>>>
>>>>> Nino Martinez Wael
>>>>> Java Specialist @ Jayway DK
>>>>> http://www.jayway.dk
>>>>> +45 2936 7684
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> --
>>> -Wicket for love
>>>
>>> Nino Martinez Wael
>>> Java Specialist @ Jayway DK
>>> http://www.jayway.dk
>>> +45 2936 7684
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: avoid ajax response evaluate javascript

Posted by francisco treacy <fr...@gmail.com>.
i've been using the aforementioned toggle behavior almost always in
ajaxy pages, and in that case they work fine.

basically that means i add toggle behaviors to components in a page.
when i call an ajax link, toggle works ok  because the isTemporary()
method of the behavior returns *true* (otherwise it would attach the
toggle effect contribution to the <header-contribution> part of the
response and it would blow things up - i.e. triggering more than once
a certain toggle effect).

however, i now started using that in pages that use normal links (not
ajax). so when i get the (non ajax) response for the linked page, as
the behavior is temporary, it won't contribute to the header anymore.
thus breaking the effect.

say page1 links to page1b [a new version of page1] when i "diff page1
page1b " i roughly get this:

24,28d23
< <script type="text/javascript"
src="resources/myapp.wicket.components.jquery.JQueryEffectCoreResourceReference/jquery-1.2.6.effects.core.js"></script>
< <script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/
< Wicket.Event.add(window, "domready", function() {
$('#optionalInfoLink58').click(function() {
$('#OptionalInfoArea59').slideToggle(450); }) ;});
< /*-->]]>*/</script>

i.e. the toggle effect won't work in page1b because "function() {
$('#optionalInfoLink58').click(function() {
$('#OptionalInfoArea59').slideToggle(450); }) ;}" is not present in
that page at all. note this doesn't pose a problem if i refresh
certain components via ajax because the original page still contains
this "javascript listener" in the header.

my question: is there a way to tell inside isTemporary() whether the
request was ajax or normal, to return true or false according to that?
other suggestions?

francisco


On Thu, Nov 6, 2008 at 2:45 PM, francisco treacy
<fr...@gmail.com> wrote:
>> It did.. You could try the isTemporary (return true) on the behavior, it
>
> thanks nino... that *is* the solution, works like a charm
>
> my mistake for not paying attention to the last bits of the javadoc
> ibehavior page :)
>
> "boolean isTemporary()
>
>    Specifies whether or not this behavior is temporary. Temporary
> behaviors are removed at the end of request. Such behaviors are useful
> for modifying component rendering only when it renders next. Usecases
> include javascript effects, initial clientside dom setup, etc. "
>
> ... couldn't be more clear...
>
> cheers,
>
> francisco
>
> On Thu, Nov 6, 2008 at 2:22 PM, Nino Saturnino Martinez Vazquez Wael
> <ni...@jayway.dk> wrote:
>> Hi Francisco
>>
>> It did.. You could try the isTemporary (return true) on the behavior, it
>> could mean that it will only add the behavior for that request, but I am not
>> sure.. Or you could try creating a new markupcontainer
>> (listOfCommentsContainer), it'll give it a new id..
>>
>> Or you could stuff in some logic as a ajaxcalldecorator on your link, that
>> will clean it up in pure js...
>>
>> I had some difficulties with exactly this when I did the wicket reaction
>> game.
>>
>> I hope this helpes..
>>
>> francisco treacy wrote:
>>>>
>>>> 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
>>> <ni...@jayway.dk> 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
>>>>> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> -Wicket for love
>>>>>>
>>>>>> Nino Martinez Wael
>>>>>> Java Specialist @ Jayway DK
>>>>>> http://www.jayway.dk
>>>>>> +45 2936 7684
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> -Wicket for love
>>>>
>>>> Nino Martinez Wael
>>>> Java Specialist @ Jayway DK
>>>> http://www.jayway.dk
>>>> +45 2936 7684
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

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


Re: avoid ajax response evaluate javascript

Posted by francisco treacy <fr...@gmail.com>.
> It did.. You could try the isTemporary (return true) on the behavior, it

thanks nino... that *is* the solution, works like a charm

my mistake for not paying attention to the last bits of the javadoc
ibehavior page :)

"boolean isTemporary()

    Specifies whether or not this behavior is temporary. Temporary
behaviors are removed at the end of request. Such behaviors are useful
for modifying component rendering only when it renders next. Usecases
include javascript effects, initial clientside dom setup, etc. "

... couldn't be more clear...

cheers,

francisco

On Thu, Nov 6, 2008 at 2:22 PM, Nino Saturnino Martinez Vazquez Wael
<ni...@jayway.dk> wrote:
> Hi Francisco
>
> It did.. You could try the isTemporary (return true) on the behavior, it
> could mean that it will only add the behavior for that request, but I am not
> sure.. Or you could try creating a new markupcontainer
> (listOfCommentsContainer), it'll give it a new id..
>
> Or you could stuff in some logic as a ajaxcalldecorator on your link, that
> will clean it up in pure js...
>
> I had some difficulties with exactly this when I did the wicket reaction
> game.
>
> I hope this helpes..
>
> francisco treacy wrote:
>>>
>>> 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
>> <ni...@jayway.dk> 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
>>>> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> -Wicket for love
>>>>>
>>>>> Nino Martinez Wael
>>>>> Java Specialist @ Jayway DK
>>>>> http://www.jayway.dk
>>>>> +45 2936 7684
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> -Wicket for love
>>>
>>> Nino Martinez Wael
>>> Java Specialist @ Jayway DK
>>> http://www.jayway.dk
>>> +45 2936 7684
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: avoid ajax response evaluate javascript

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
Hi Francisco

It did.. You could try the isTemporary (return true) on the behavior, it 
could mean that it will only add the behavior for that request, but I am 
not sure.. Or you could try creating a new markupcontainer 
(listOfCommentsContainer), it'll give it a new id..

Or you could stuff in some logic as a ajaxcalldecorator on your link, 
that will clean it up in pure js...

I had some difficulties with exactly this when I did the wicket reaction 
game.

I hope this helpes..

francisco treacy wrote:
>> 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
> <ni...@jayway.dk> 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
>>> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> --
>>>> -Wicket for love
>>>>
>>>> Nino Martinez Wael
>>>> Java Specialist @ Jayway DK
>>>> http://www.jayway.dk
>>>> +45 2936 7684
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>>         
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>       
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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


Re: avoid ajax response evaluate javascript

Posted by francisco treacy <fr...@gmail.com>.
> 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
<ni...@jayway.dk> 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
>> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> -Wicket for love
>>>
>>> Nino Martinez Wael
>>> Java Specialist @ Jayway DK
>>> http://www.jayway.dk
>>> +45 2936 7684
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: avoid ajax response evaluate javascript

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
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
> <ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>       
>> --
>> -Wicket for love
>>
>> Nino Martinez Wael
>> Java Specialist @ Jayway DK
>> http://www.jayway.dk
>> +45 2936 7684
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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


Re: avoid ajax response evaluate javascript

Posted by francisco treacy <fr...@gmail.com>.
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
<ni...@jayway.dk> 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> --
> -Wicket for love
>
> Nino Martinez Wael
> Java Specialist @ Jayway DK
> http://www.jayway.dk
> +45 2936 7684
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: avoid ajax response evaluate javascript

Posted by Nino Saturnino Martinez Vazquez Wael <ni...@jayway.dk>.
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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   

-- 
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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