View previous topic :: View next topic |
Author |
Message |
glowens Smarty Rookie
Joined: 05 Apr 2008 Posts: 11
|
Posted: Wed Aug 27, 2008 2:59 pm Post subject: Smarty with Superfish and JQuery |
|
|
I am running the Superfish menu and trying to get the following jquery code to work with Smarty. It appears the code is having a problem with the $. Below is the code
Code: | {literal}
<script type="text/javascript">
$(document).ready(function(){
$("ul.sf-menu").superfish({
pathClass: 'current'
});
});
</script>{/literal} |
Any suggestions? |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Wed Aug 27, 2008 3:28 pm Post subject: |
|
|
Since you put it in a {literal}{/literal} block it seems to be no Smarty related issue. _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
glowens Smarty Rookie
Joined: 05 Apr 2008 Posts: 11
|
Posted: Wed Aug 27, 2008 3:35 pm Post subject: |
|
|
I believe the issue is with the $ I change the code to
Code: | jQuery(document).ready(function(){
$("ul.sf-menu").superfish({
pathClass: 'current'
});
}); |
And it at least loads the code but now I get a different error with the $.
Is there a Jquery pluggin for smarty? |
|
Back to top |
|
glowens Smarty Rookie
Joined: 05 Apr 2008 Posts: 11
|
Posted: Wed Aug 27, 2008 3:49 pm Post subject: |
|
|
More info
I call Superfish using the basic code below but it will not work
$(document).ready(function(){
$("ul.sf-menu").superfish({
pathClass: 'current'
});
});
I changed the code to the following and it appears to call the code.
jQuery(document).ready(function(){
$("ul.sf-menu").superfish({
pathClass: 'current'
});
});
But I get the following error
this.cloneNode is not a function
[Break on this error] return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function()...
I beleive the issue is with the $. I tested this with the following.
jQuery(document).ready(function(){
alert('test')
});
});
and the alert is displayed. If I change the JQuery back to a $ it will not work.
Any ideas or other ways to initiate the Superfish code.[/code] |
|
Back to top |
|
amirsadig Smarty Rookie
Joined: 14 May 2004 Posts: 12
|
Posted: Wed Aug 27, 2008 4:24 pm Post subject: |
|
|
do you use different javascript like prototyp ..
most of them use $ which get conflict with jquery.
do the following
var $jQ = jQuery;
$jQ(document).ready(function(){
$jQ("ul.sf-menu").superfish({
pathClass: 'current'
});
});
and read the following site:
http://docs.jquery.com/Using_jQuery_with_Other_Libraries |
|
Back to top |
|
glowens Smarty Rookie
Joined: 05 Apr 2008 Posts: 11
|
Posted: Wed Aug 27, 2008 4:31 pm Post subject: |
|
|
Thanks
I also found the document you reference and made the changes but now I get another error. It works when I do not use smarty. I have identical code in my smarty site and my non-smarty site.
this.cloneNode is not a function
[Break on this error] return this.cloneNode(true);});var clone=ret.find("*").andSelf().each(function()... |
|
Back to top |
|
amirsadig Smarty Rookie
Joined: 14 May 2004 Posts: 12
|
Posted: Wed Aug 27, 2008 4:40 pm Post subject: |
|
|
it is not related with smarty, it is related with javascript.
and it may still the same problem. try to look at the implementation of the Superfish plugin.
most plugin start with:
(function($) {
// plugin code here, use $ as much as you like
})(jQuery); |
|
Back to top |
|
glowens Smarty Rookie
Joined: 05 Apr 2008 Posts: 11
|
Posted: Wed Aug 27, 2008 4:43 pm Post subject: |
|
|
Okay. The superfish.js uses function($). Do I need to replace the $ with $jQ as well? |
|
Back to top |
|
glowens Smarty Rookie
Joined: 05 Apr 2008 Posts: 11
|
Posted: Wed Aug 27, 2008 7:04 pm Post subject: |
|
|
Forget my last question. I have been working on this so long I am brain dead and not think properly.
BTW I have narrowed it down to something with prototype.js is interfering with the jquery.min.js.
Any idea? |
|
Back to top |
|
glowens Smarty Rookie
Joined: 05 Apr 2008 Posts: 11
|
Posted: Wed Aug 27, 2008 10:14 pm Post subject: |
|
|
Figured it out. my jsquery.mim.js was interfering with the effect.js file from scriptulaous. I upgraded to the latest version and the problem is fixed. |
|
Back to top |
|
|