You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "prasad.bhandagi" <pr...@marsh.com> on 2014/10/30 01:08:01 UTC

Wicket jQuery js loaded twice when modal window opened

I have a Wicket v6 page with couple of AjaxButtons. When the AjaxButton is
clicked, am opening a modal window using jQuery ui Dialog passing the URL of
a second page. The second wicket page also has a AjaxButton. When wicket
fetches the second page using Ajax to be rendered in the modal window, it
loads jQuery js again.

I think this causes issues and it gives me error subsequently
"jQuery(...).dialog is not a function".

Is there a way I can tell Wicket to NOT to load the jQuery js when rendering
the page in the modal window? Wicket Ajax components automatically add
jQuery reference always. Am looking for a way to remove the jQuery reference
before the page is rendered.

Note: I am not using the Wicket extension for Modal Window. Am using jQuery
UI Dialog directly to open modal window. But I think the problem of jQuery
getting loaded again will occur when Modal Window used also.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-jQuery-js-loaded-twice-when-modal-window-opened-tp4668156.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket jQuery js loaded twice when modal window opened

Posted by "prasad.bhandagi" <pr...@marsh.com>.
Yes, the anticache parameter was being added by jQuery as I was trying to get
the content for new page in modal window using jQuery ajax get. 
I will load the new page in modal window using iframe to avoid the
javascript of new page affecting the page in parent window, to resolve the
issue.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-jQuery-js-loaded-twice-when-modal-window-opened-tp4668156p4668417.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket jQuery js loaded twice when modal window opened

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

The anti cache parameter is added by jQuery itself when $.ajax({cache:
false, ...}) - http://api.jquery.com/jquery.ajax/

ack-grep '_=' wicket-core/src/main/java/
wicket-core/src/main/java/org/apache/wicket/resource/jquery/jquery-1.11.1.js
8551: rts = /([?&])_=[^&]*/,
9105: cacheURL.replace( rts, "$1_=" + nonce++ ) :
9108: cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;

wicket-ajax sets cache to false to avoid cached Ajax responses:
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js#L671

Can you reproduce this with a plain (i.e. no third party libs) Wicket
quickstart ?
If YES then please create a ticket and attach the quickstart.
Thanks!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Oct 30, 2014 at 3:35 PM, prasad.bhandagi <pr...@marsh.com>
wrote:

> @Martin
>
> When the first page is loaded, below is the url:
>
> http://localhost:7001/ahc/prol/wicket/resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery-1.10.1-ver-1372037384000.js
>
> When the second page is loaded in modal window, below is the url:
>
> http://localhost:7001/ahc/prol/wicket/resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery-1.10.1-ver-1372037384000.js?_=1414675886491
>
> Wicket for some reason is appending a query parameter the second time.
> Hence
> it is loading jQuery again when the modal window is opened.
> If the url was the same, Wicket client side filters would have not loaded
> jQuery again as you said.
> Any idea on why the "_" query parameter is being appended the second time
> and if it can be avoided?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-jQuery-js-loaded-twice-when-modal-window-opened-tp4668156p4668168.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Wicket jQuery js loaded twice when modal window opened

Posted by "prasad.bhandagi" <pr...@marsh.com>.
@Martin

When the first page is loaded, below is the url:
http://localhost:7001/ahc/prol/wicket/resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery-1.10.1-ver-1372037384000.js

When the second page is loaded in modal window, below is the url:
http://localhost:7001/ahc/prol/wicket/resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery-1.10.1-ver-1372037384000.js?_=1414675886491

Wicket for some reason is appending a query parameter the second time. Hence
it is loading jQuery again when the modal window is opened.
If the url was the same, Wicket client side filters would have not loaded
jQuery again as you said.
Any idea on why the "_" query parameter is being appended the second time
and if it can be avoided?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-jQuery-js-loaded-twice-when-modal-window-opened-tp4668156p4668168.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Wicket jQuery js loaded twice when modal window opened

Posted by Maxim Solodovnik <so...@gmail.com>.
My bad, sorry

On 30 October 2014 13:15, Martin Grigorov <mg...@apache.org> wrote:

> @Maxim,
>
> It seems you didn't read the message till the end. It says that it uses
> JQuery UI Dialog.
>
> @Prasad: Wicket filters out any JS or CSS resource at the client side if it
> is already loaded. I.e. The server may contribute <script
> src=".../jquery.js"> but while processing the Ajax response
> (<ajax-response> XML element) wicket-ajax-jquery.js will take the value of
> the src attribute and check whether there is another <script> element in
> the document with the same url. If there is then the contribution is
> ignored.
> Please check whether the urls are same.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Thu, Oct 30, 2014 at 5:09 AM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > I believe this is because you are using ModalWindow with page, Maybe you
> > better use it with panel?
> > Or use dialog from wicket-jqueryui:
> > http://www.7thweb.net/wicket-jquery-ui/dialog/MessageDialogPage ?
> >
> > On 30 October 2014 06:08, prasad.bhandagi <pr...@marsh.com>
> > wrote:
> >
> > > I have a Wicket v6 page with couple of AjaxButtons. When the AjaxButton
> > is
> > > clicked, am opening a modal window using jQuery ui Dialog passing the
> URL
> > > of
> > > a second page. The second wicket page also has a AjaxButton. When
> wicket
> > > fetches the second page using Ajax to be rendered in the modal window,
> it
> > > loads jQuery js again.
> > >
> > > I think this causes issues and it gives me error subsequently
> > > "jQuery(...).dialog is not a function".
> > >
> > > Is there a way I can tell Wicket to NOT to load the jQuery js when
> > > rendering
> > > the page in the modal window? Wicket Ajax components automatically add
> > > jQuery reference always. Am looking for a way to remove the jQuery
> > > reference
> > > before the page is rendered.
> > >
> > > Note: I am not using the Wicket extension for Modal Window. Am using
> > jQuery
> > > UI Dialog directly to open modal window. But I think the problem of
> > jQuery
> > > getting loaded again will occur when Modal Window used also.
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/Wicket-jQuery-js-loaded-twice-when-modal-window-opened-tp4668156.html
> > > Sent from the Users forum mailing list archive at Nabble.com.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>



-- 
WBR
Maxim aka solomax

Re: Wicket jQuery js loaded twice when modal window opened

Posted by Martin Grigorov <mg...@apache.org>.
@Maxim,

It seems you didn't read the message till the end. It says that it uses
JQuery UI Dialog.

@Prasad: Wicket filters out any JS or CSS resource at the client side if it
is already loaded. I.e. The server may contribute <script
src=".../jquery.js"> but while processing the Ajax response
(<ajax-response> XML element) wicket-ajax-jquery.js will take the value of
the src attribute and check whether there is another <script> element in
the document with the same url. If there is then the contribution is
ignored.
Please check whether the urls are same.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Oct 30, 2014 at 5:09 AM, Maxim Solodovnik <so...@gmail.com>
wrote:

> I believe this is because you are using ModalWindow with page, Maybe you
> better use it with panel?
> Or use dialog from wicket-jqueryui:
> http://www.7thweb.net/wicket-jquery-ui/dialog/MessageDialogPage ?
>
> On 30 October 2014 06:08, prasad.bhandagi <pr...@marsh.com>
> wrote:
>
> > I have a Wicket v6 page with couple of AjaxButtons. When the AjaxButton
> is
> > clicked, am opening a modal window using jQuery ui Dialog passing the URL
> > of
> > a second page. The second wicket page also has a AjaxButton. When wicket
> > fetches the second page using Ajax to be rendered in the modal window, it
> > loads jQuery js again.
> >
> > I think this causes issues and it gives me error subsequently
> > "jQuery(...).dialog is not a function".
> >
> > Is there a way I can tell Wicket to NOT to load the jQuery js when
> > rendering
> > the page in the modal window? Wicket Ajax components automatically add
> > jQuery reference always. Am looking for a way to remove the jQuery
> > reference
> > before the page is rendered.
> >
> > Note: I am not using the Wicket extension for Modal Window. Am using
> jQuery
> > UI Dialog directly to open modal window. But I think the problem of
> jQuery
> > getting loaded again will occur when Modal Window used also.
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/Wicket-jQuery-js-loaded-twice-when-modal-window-opened-tp4668156.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> WBR
> Maxim aka solomax
>

Re: Wicket jQuery js loaded twice when modal window opened

Posted by Maxim Solodovnik <so...@gmail.com>.
I believe this is because you are using ModalWindow with page, Maybe you
better use it with panel?
Or use dialog from wicket-jqueryui:
http://www.7thweb.net/wicket-jquery-ui/dialog/MessageDialogPage ?

On 30 October 2014 06:08, prasad.bhandagi <pr...@marsh.com> wrote:

> I have a Wicket v6 page with couple of AjaxButtons. When the AjaxButton is
> clicked, am opening a modal window using jQuery ui Dialog passing the URL
> of
> a second page. The second wicket page also has a AjaxButton. When wicket
> fetches the second page using Ajax to be rendered in the modal window, it
> loads jQuery js again.
>
> I think this causes issues and it gives me error subsequently
> "jQuery(...).dialog is not a function".
>
> Is there a way I can tell Wicket to NOT to load the jQuery js when
> rendering
> the page in the modal window? Wicket Ajax components automatically add
> jQuery reference always. Am looking for a way to remove the jQuery
> reference
> before the page is rendered.
>
> Note: I am not using the Wicket extension for Modal Window. Am using jQuery
> UI Dialog directly to open modal window. But I think the problem of jQuery
> getting loaded again will occur when Modal Window used also.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-jQuery-js-loaded-twice-when-modal-window-opened-tp4668156.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
WBR
Maxim aka solomax