You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by trlt <tr...@gmail.com> on 2014/03/25 02:53:32 UTC
jQuery noConflict() and wicket 6
I wrote a simple test program to understand how jQuery.noConflict() works
with Wicket 6. The program uses 2 different jQuery libraries (jQuery 1.11.0
by Wicket 6 and jQuery 1.4.4 by someone else), and can be explained in its
*.html file:
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<meta charset="utf-8" />
<title>Apache Wicket Quickstart</title>
</head>
<body>
<p>
click <#> ( ajax link )
</p>
</body>
</html>
"decorator.js" is a program implemented by another developer. It also adds
jQuery 1.4.4 dynamically to the page. To simplify the code, I only included
the line that causes the problem:
(function($) {
$(document).ready(function() {
$('head').prepend('');
});
})(jQuery);
Problem: Wicket Ajax link (c1-link) no longer works (onClick() is never
called). jQuery object now references version 1.4.4. In Firebug, I see the
following error:
TypeError: jQuery(...).on is not a function
jQuery(el).on(type, data, fn); //wicket...4000.js (line 169)
Question: How can I reset the jQuery object to 1.11.0 for the Wicket Ajax
call? Can someone explain to me the execution order of the different jQuery
libraries used in the program? I tried to reset it by calling
$.noConflict() after decorator.js, but that didn't work (still points to
1.4.4). I'm not too sure how to unset it since it's added dynamically after
the DOM object has been created.
I can update the program to use jQuery 1.7+ in place of 1.4.4 to solve the
problem, but I want to understand how 2 different libraries can be used in
the same page. Hoping someone can help!
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/jQuery-noConflict-and-wicket-6-tp4665117.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: jQuery noConflict() and wicket 6
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
I haven't tried it but this may work:
the page should load the scripts in this order:
1) jQuery 1.11.0 (the one coming with Wicket)
2) wicket-ajax-jquery.js
3) var jQuery1_11 = jQuery.noConflict();
4) jquery 1.4.4
5) your-custom-component.js
Try it
Martin Grigorov
Wicket Training and Consulting
On Tue, Mar 25, 2014 at 3:53 AM, trlt <tr...@gmail.com> wrote:
> I wrote a simple test program to understand how jQuery.noConflict() works
> with Wicket 6. The program uses 2 different jQuery libraries (jQuery 1.11.0
> by Wicket 6 and jQuery 1.4.4 by someone else), and can be explained in its
> *.html file:
>
> <!DOCTYPE html>
> <html xmlns:wicket="http://wicket.apache.org">
> <head>
> <meta charset="utf-8" />
> <title>Apache Wicket Quickstart</title>
>
>
>
> </head>
> <body>
> <p>
> click <#> ( ajax link )
> </p>
> </body>
> </html>
>
> "decorator.js" is a program implemented by another developer. It also adds
> jQuery 1.4.4 dynamically to the page. To simplify the code, I only
> included
> the line that causes the problem:
>
> (function($) {
> $(document).ready(function() {
> $('head').prepend('');
> });
> })(jQuery);
>
>
> Problem: Wicket Ajax link (c1-link) no longer works (onClick() is never
> called). jQuery object now references version 1.4.4. In Firebug, I see the
> following error:
>
> TypeError: jQuery(...).on is not a function
> jQuery(el).on(type, data, fn); //wicket...4000.js (line 169)
>
> Question: How can I reset the jQuery object to 1.11.0 for the Wicket Ajax
> call? Can someone explain to me the execution order of the different
> jQuery
> libraries used in the program? I tried to reset it by calling
> $.noConflict() after decorator.js, but that didn't work (still points to
> 1.4.4). I'm not too sure how to unset it since it's added dynamically
> after
> the DOM object has been created.
>
> I can update the program to use jQuery 1.7+ in place of 1.4.4 to solve the
> problem, but I want to understand how 2 different libraries can be used in
> the same page. Hoping someone can help!
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/jQuery-noConflict-and-wicket-6-tp4665117.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
>
>